The sapply() function can be used to calculate descriptive statistics other than the ones calculated by the summary() function for each variable in a data frame.įor example, the sapply() function above calculates the standard deviation of each variable in a data frame. Method 2: Use sapply() Function sapply(my_data, sd, na. The summary() function calculates the following values for each variable in a data frame in R:
Method 1: Use summary() Function summary(my_data)
There are two functions we can use to calculate descriptive statistics in R: They help us gain an understanding of where the center of the dataset is located along with how spread out the values are in the dataset.
Descriptive statistics are values that describe a dataset.