Using R Studio, we can also calculate the:
Mean of a data set.
Calculating Mean in R
For calculating mean in R, we use the mean() function.
The syntax for calculating mean in R is:
mean(x, trim = 0, na.rm = FALSE, ...)
Description of the parameters used:
x is the input vector.
trim is used to drop some observations from both end of the sorted vector.
na.rm is used to remove the missing values from the input vector.
Median of a data set.
Calculating Median in R
For calculating median in R, we use the median() function.
The syntax for calculating mean in R is:
median(x, na.rm = FALSE)
Description of the parameters used:
x is the input vector.
na.rm is used to remove the missing values from the input vector.
Mode of a data set.
Calculating Mode in R
A mode is defined as the value with the highest frequency of occurrences in a set of data. The mode can be determined both for numeric and character data.
For calculating the mode, we do not have any inbuilt function in R. Here; we create a user-defined function to get the mode of a data set.