Introduction to data frames
Data frame structure
Accessing columns in a data frame
Accessing rows of a data frame
Accessing rows and columns combined in a data frame
Data frame analysis
26. Summary for a whole data frame
Summary

Instruction

Well done! The summary() function can also be called on a whole data frame! In that case, R will calculate summary statistics for each numeric column in parallel.

As a result, R will display summary statistics for each numeric column of your table. Calculations will be performed only on numeric columns. R will skip character columns, which will be marked in the output as "character" so the analyst knows why statistics were not presented for such columns.

Let's try to use summary() on the entire cities data frame:

summary(cities)

Here's the result:

   country          ...     latitude        ...     
 Length:205         ...   Min.   :-21.03    ... 
 Class :character   ...   1st Qu.: 44.85    ...  
 Mode  :character   ...   Median : 49.50    ... 
                          Mean   : 45.74    ... 
                          3rd Qu.: 52.05    ... 
                          Max.   : 54.78    ... 

As you can see, country and city are character columns, so summary statistics cannot be displayed for them. For the other columns, statistics were calculated and presented in the same output at once.

Exercise

Use the summary() function on the whole countries data frame. Observe the results.