Hello everybody,
This is Michael, and today’s post will be about basic summarization of R Data. I thought this would be an appropriate place to continue from R Lesson 1: Basic R commands (I’ll be using the dataset from that post).
Let’s start off simple by using the summary() command to display a summary of the age field.
As you can see, the output shows the minimum age for any congressperson (25), the end of the 1st quartile (45.4), the median age (53), the mean age (53.31), the beginning of the third quartile (60.55), and the maximum age (98.1). But what does this all mean?
- The minimum is obviously the minimum age amongst the congresspeople-25 years
- The 1st quartile is the age between the minimum and the mean (45.4)
- In other words, the youngest 25% of congresspeople were between 25 and 45.4 years old (at the start of their terms)
- The median is the center of all the ages amongst the congresspeople-53 years in this case
- 50% of congresspeople were between 45.4 and 60.55 years old (at the start of their terms)
- The mean is the average of all the ages
- The 3rd quartile is the age between the median and the maximum (60.55)
- In other words, the oldest 25% of congresspeople were between 60.55 and 98.1 years old (at the start of their terms)
- The maximum is obviously the maximum age amongst the congresspeople-98.1 years
However, if you use summary on a non-numeric field, such as state, the counts for each observation (in this case, how many times each state appears in the dataset).

Another summary command I will discuss is table(), which shows all values of a variable along with each values’ frequencies (how many times that value appears in the dataset).
Below is a table displaying the number of congresspeople who are representatives, as well as those who are senators.
Now here’s what the table would look like if we add another value (I’ll use congress)
Like the last table, this table shows the number of representatives and senators, except divided up by congress (80th to 113th specifically).
Thanks for reading,
Michael