5  Functions

Key inbuilt functions in R

sum(), length(), sqrt(),mean(), summary(), View()

sum() Function

The sum() function calculates the total sum of all the elements in a numeric vector.


length() Function

The length() function returns the number of elements in a vector (or other objects). In the code block below, you can change the title of the plot or the number of data points and then click “Run Code” to see your changes live.

sqrt() Function

The sqrt() function calculates the square root of each element in a numeric vector.

mean() Function

The mean() function calculates the arithmetic mean (average) of the elements in a numeric vector.

summary() function

The summary() function in R provides a concise statistical summary of objects like vectors, matrices, data frames, and results of model fitting.

data.frame() function

data.frame() function is used to create data frames, which are table-like structures consisting of rows and columns. - Data frames are one of the most important data structures in R, especially for statistical modeling and data analysis.

View() function

View() function is used to invoke a spreadsheet-like data viewer on a data frame, matrix, or other objects that can be coerced into a data frame. - This function is particularly useful during interactive sessions to inspect data visually.