Built-in Function in R Programming Language
Built-in Function are the functions that are already existing in R language and you just need to call them to use.
Here we will use built-in functions like sum(), max() and min().
R
# Find sum of numbers 4 to 6. print ( sum (4:6)) # Find max of numbers 4 and 6. print ( max (4:6)) # Find min of numbers 4 and 6. print ( min (4:6)) |
Output
[1] 15
[1] 6
[1] 4
Other Built-in Functions in R:
Let’s look at the list of built-in R functions and their uses:
Functions |
Syntax |
---|---|
Mathematical Functions | |
calculates a number’s absolute value. | |
calculates a number’s square root. | |
rounds a number to the nearest integer. | |
calculates a number’s exponential value | |
which calculates a number’s natural logarithm. | |
calculates a number’s cosine, sine, and tang. | |
Statistical Functions | |
A vector’s arithmetic mean is determined by the mean() function. | |
A vector’s median value is determined by the median() function. | |
calculates the correlation between two vectors. | |
calculates the variance of a vector and calculates the standard deviation of a vector. | |
Data Manipulation Functions | |
returns the unique values in a vector. | |
subsets a data frame based on conditions. | |
groups data according to a grouping variable. | |
uses ascending or descending order to sort a vector. | |
File Input/Output Functions | |
reads information from a CSV file. | |
publishes information to write a CSV file. | |
reads information from a tabular. | |
creates a tabular file with data. |
Functions in R Programming
A function accepts input arguments and produces the output by executing valid R commands that are inside the function.
Functions are useful when you want to perform a certain task multiple times.
In R Programming Language when you are creating a function the function name and the file in which you are creating the function need not be the same and you can have one or more functions in R.
Contact Us