Some of the most commonly used functions in R are .- diff function As far as the prediction of the time series is concerned diff function proves to be the best option. Length function The length function is mainly used for counting the rows in a vector. One Argument Function The One Argument function in R helps to accept a value and provide the square of that value. We input a value ‘n’ and the function gives out it’s value. The following illustration explains the same. square_function<- function(n) { # compute the square of integer `n` n^2 } # calling the function and passing value 4 square_function(4) Multi Argument function This function in R helps us to write a function in more than one argument. For instance consider the following function, ‘times’. times <- function(x,y) { x*y } times(2,4) Output. ## [1] 8 In the above illustration 2 times 4 gives the output as 8. Environment Scoping Environment with respect to ‘R’ refers to a collection of functions, variables, dataframes. We have a global environment, which is the top level environment and local environment.
In the diagram below the top level global environment is called ‘env’, the local environment ‘LOC’ and the data frames ‘loc_df’ is the name of the data frame and the name of the environment that contains the data. The top level environment is global and is defined by ‘env’.