• No products in the cart.

# 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 , 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,

`"a<-toupper(id)"`

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.

20th June 2017
0 responses on "103.1.7 R Functions"