Home / R / 103.1.7 R Functions

103.1.7 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 , ignore.case=FALSE, 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.

About admin

Check Also

203.5.6 Neural Network Intuition

Before going further into neural network algorithm, we need to understand and break down how …

Leave a Reply

Your email address will not be published. Required fields are marked *