103.1.7 R Functions

Different Functions in R.

In previous section, we studied about R Lists, now we will be studying about R Functions.

We have already started using R functions. It is just like using any function in any other language. We can call the function and give the particular parameters. We have started using concatenate c() function already and we are using is.vector() or str() function.

The numeric functions include abs(x), sqrt(x), ceiling(x), floor(x), trunc(x), round(x, digits=n) ,signif(x, digits=n), cos(x), sin(x), tan(x) ,log(x), log10(x), exp(x).

And the string functions includes substr(x, start=n1, stop=n2), toupper(x), grep(pattern, x ,, fixed=FALSE)

Here are some examples.

“y= abs(-20)”

abs is a function which will find the absolute value and store it in y.

We are trying string functions cust_id = “Cust123456”. We can create a substring of cust_id from 5:10. [id<-substr(cust_id,5,10)]. Here,


will convert everything to upper case and

grep(4, cust_id)

is a function which will search a particular value in the variable.

So this was a short note on the R Functions.

Next post is about R History and Scripts.

In next section, we will be studying about R History and Scripts.

0 responses on "103.1.7 R Functions"

Leave a Message

Blog Posts

Hurry up!!!

"use coupon code for FLAT 30% discount"  datascientistoffer        ___________________________________      Subscribe to our youtube channel. Get access to video tutorials.                

Contact Us

Statinfer Software Solutions#647 2nd floor 1st Main, Indira Nagar 1st Stage, 100 feet road,Indranagar Bangalore,Karnataka, Pin code:-560038 Landmarks: Opp. Namma Metro Pillar 48.

Connect with us

linkin fn twitter g

How to become a Data Scientist.?