Site icon R-bloggers

User Defined Functions in R Exercises (Part 1)

[This article was first published on R-exercises, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

In the Exercises we will discuss User Defined Function in R

Answers to the exercises are available here.

Exercise 1

Create a function to print square of number

Exercise 2

Create a function to print a number raise to another with the one argument a default argument
Exercise 3

Create a function to print class of an argument

Exercise 4

Create a function to accept two matrix arguments and do matrix operations with same.

Exercise 5

Create a user defined function to accept a name from the user

Exercise 6

Create a user defined function to accept values from the user using scan and return the values

Exercise 7

Create a user defined function to create a matrix and return the same.

Exercise 8

Create a function to take two arguments, one student marks and other student names and plot a graph based on the same.

Exercise 9

Create a function to accept an employee data frame(Name,Gender,Age,Designation & SSN) and print the First & Fifth employee as well as the Names & the Designation of all the employees in the function

Exercise 10

Create a function to create an employee data frame(Name,Gender,Age,Designation & SSN) and return the Name,Age & Designation of all employees.

Related exercise sets:

  1. Matrix exercises
  2. Functions exercises vol. 2
  3. Data frame exercises Vol. 2
  4. Explore all our (>1000) R exercises
  5. Find an R course using our R Course Finder directory

To leave a comment for the author, please follow the link and comment on their blog: R-exercises.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.