Published on Sep 23,2014
1.1K Views
Email Post

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.

Introduction to Functions in R

cbind 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

About Author
edureka
Published on Sep 23,2014

Share on

Browse Categories

Comments
0 Comments