Section 2.4 Summary Function
There may be too much information to review if you try to read the entire content displayed from the view function. So, reviewing summarized information from our data frame may be better. The
summary() function gives a quick rundown of whatβs inside a data frame, showing both the layout and key statistics for each variable.
summary(object = GSS.2012)
The results show the minimum, 1st quartile, median, mean, 3rd quartile, and maximum values. What about NAβs? NAβs indicate the number of missing values in each variable. For example, the summary statistics provided for
AGE are as follows:
-
Minimum (Min.): 18.00
-
1st Quartile (1st Qu.): 33.00
-
Median: 47.00
-
Mean: 48.19
-
3rd Quartile (3rd Qu.): 61.00
-
Maximum (Max.): 89.00
-
Number of missing values (NAβs): 5
These statistics give insights into the distribution of ages in the dataset. For instance, the youngest person in the dataset is 18 years old. A quarter of the people are 33 or younger. The median age is 47, meaning half are younger, and half are older than that. The average age is a bit higher than the median age at 48.19 years, which suggests there might be some older individuals raising the average. Three-quarters of the people are 61 or younger, and the oldest person is 89. Five missing age values that need to be handled based on what kind of analysis or modeling youβre doing.
