Business Analytics with R (29 Blogs) Become a Certified Professional

Introduction to Functions in R

Last updated on Oct 22,2020 3.9K Views

Functions in R

Functions in R can be user defined and in-built functions. To define a function, a name is assigned and the keyword function is used to denote the start of the function and its argument list. Functions are created using the function () directive and are stored as R objects just like anything else. In particular, they are R objects of class function. Functions can be passed as arguments to other functions. Functions can be nested, so that you can define a function inside another function.

User-defined Function

A user-defined function is a function provided by the user of a program or environment in a context where the usual assumption is that functions are built into the program or environment.

The variable x is a formal parameter of the function. When the function is called, it is passed as an arguement that provides a value for the formal parameter.

In-built Function

There is a function called the repeat function which means to repeat a value a number of time. Repeat series is repeat 1:6 twice as you can see in the image. All this data can be created whenever required and elements of the series can also be repeated.

Inbuilt Functions in R - Functions in R - Edurekacbind Function and rbind Function

cbind function combines vector, matrix or data frame by columns. rbind function combines vector, matrix or data frame by rows.

Introduction to Functions in R Introduction to Functions in R

Got a question for us?? Please mention them in the comments section and we will get back to you.

Related Posts:

Introduction to Supervised Learning

What is R?

Get started with Data Science


Join the discussion

Browse Categories

webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP

Subscribe to our Newsletter, and get personalized recommendations.

image not found!
image not found!

Introduction to Functions in R