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  

abs()

calculates a number’s absolute value.

sqrt()

calculates a number’s square root. 

  round()

rounds a number to the nearest integer.

exp()

calculates a number’s exponential value

log()

which calculates a number’s natural logarithm.

cos(), sin(), and tan()

calculates a number’s cosine, sine, and tang.
Statistical Functions  

mean()

 A vector’s arithmetic mean is determined by the mean() function. 

median()

 A vector’s median value is determined by the median() function.

cor()

calculates the correlation between two vectors.

var()

 calculates the variance of a vector and calculates the standard deviation of a vector.
Data Manipulation Functions  

unique()

 returns the unique values in a vector.

subset()

subsets a data frame based on conditions.

aggregate()

 groups data according to a grouping variable.

order()

uses ascending or descending order to sort a vector.
File Input/Output Functions  

read.csv()

reads information from a CSV file. 

Write.csv()

publishes information to write a CSV file.

Read. table()

reads information from a tabular.

Write.table()

 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.

Similar Reads

Creating a Function in R Programming

Functions are created in R by using the command function(). The general structure of the function file is as follows:...

Parameters or Arguments in R Functions:

Parameters and arguments are same term in functions....

Calling a Function in R

...

Types of Function in R Language

After creating a Function, you have to call the function to use it....

Built-in Function in R Programming Language

...

User-defined Functions in R Programming Language

Built-in Function: Built-in functions in R are pre-defined functions that are available in R programming languages to perform common tasks or operations. User-defined Function: R language allow us to write our own function....

R Function Examples

Built-in Function are the functions that are already existing in R language and you just need to call them to use....

Lazy Evaluations of Functions in R Programming Language

...

Contact Us