in R Language by (1.0k points)
R language important built-in functions

1 Answer

0 votes
by (1.0k points)
edited by

There are a lot of built-in function in R. R matches your input parameters with its function arguments, either by value or by position, then executes the function body. Function arguments can have default values: if you do not specify these arguments, R will take the default value.

  • General function
  • Maths function
  • Statistical function

General functions

diff() function

If you work on time series, you need to stationary the series by taking their lag values. A stationary process allows constant mean, variance and autocorrelation over time. This mainly improves the prediction of a time series. It can be easily done with the function diff(). We can build a random time-series data with a trend and then use the function diff() to stationary the series. The diff() function accepts one argument, a vector, and return suitable lagged and iterated difference.

length() function

In many cases, we want to know the length of a vector for computation or to be used in a for loop. The length() function counts the number of rows in vector x. The following codes import the cars dataset and return the number of rows.

Math functions

R has an array of mathematical functions.

abs(x)Takes the absolute value of x
log(x,base=y)Takes the logarithm of x with base y; if base is not specified, returns the natural logarithm
exp(x)Returns the exponential of x
sqrt(x)Returns the square root of x
factorial(x)Returns the factorial of x (x!)

Statistical functions




Mean of x


Median of x


Variance of x


Standard deviation of x


Standard scores (z-scores) of x


The quartiles of x


Summary of x: mean, min, max etc..

Related questions

0 votes
asked Nov 6, 2019 in R Language by MBarbieri (1.0k points)
+3 votes
asked Jul 28, 2019 in R Language by Aarav2017 (359 points)
+3 votes
asked Jul 28, 2019 in R Language by Aarav2017 (359 points)