Introduction

How are the viewership of episodes of The Office and their respective ratings related and how did that change over time?

Using the data set office_ratings compiled from https://github.com/rfordatascience/tidytuesday/blob/main/data/2020/2020-03-17/readme.md and https://en.wikipedia.org/wiki/List_of_The_Office_(American_TV_series)episodes, this report intends to answer that question.

The data includes 186 entries, one for each episode of The Office, with nine corresponding variables. Those variables include season , episode , and air_date to show the sequential order the episodes were released, title to distinguish between episodes, viewers to show the total in millions of people who watched the episode as it aired, imdb_rating to provide a rating on how well liked the episode was (as voted on the movie and TV website IMDb), and total_votes to show how many ratings were left on IMDb for that episode.

The data table was made through the DT library and the included visualizations have been made through the tidyverse library.

library(DT)
library(tidyverse)

Distributions of The Office’s Viewers, Ratings, and Total Votes

Before diving too deeply into the relationships between the variables of the dataset, it is first beneficial to understand the distributions of three key variables. Viewing the distribution of viewers, imdb_rating, and total_votes reveals the overall landscape of The Office during its highly popular and well-regarded run on TV. This general representation of the show, without any temporal component, provides a foundation for the later steps of the analysis. Using histograms, each of the three variables will be plotted to show their distribution.

ggplot(data = office_ratings) +
  geom_histogram(mapping = aes(x = viewers), bins = 20) +
  labs(x = "viewers (millions)",
       y = "# of episodes",
       title = "Distribution of viewers across all Office episodes",
       caption = "Data obtained from raw.githubusercontent.com")

Viewership of episodes of The Office ranged from around 3 million to over 22 million for a single episode. That lone 22 million viewer episode certainly appears to be an outlier, as the next highest mark is over 10 million fewer. That particular episode aired immediately after the Super Bowl, leading to an astronomically larger audience. It seems the most common viewer total fell in the 7 to 9 million range. The presence of the high outlier creates a right-skewed shape as it drags the distribution of viewers to higher positive values with low frequency. However, if that episode is disregarded, the distribution is instead more left-skewed, as the less watched episodes with 3 to 6 million viewers are less plentiful than those in the 7 to 9 million range before it steeply drops off. This information is valuable in knowing The Office often drew large audiences.

ggplot(data = office_ratings) +
  geom_histogram(mapping = aes(x = imdb_rating), bins = 15) +
  labs(x = "IMDb rating (scale from 0 to 10)",
       y = "# of episodes",
       title = "Distribution of IMDb ratings for all Office episodes",
       caption = "Data obtained from raw.githubusercontent.com")

At first glance, it appears the distribution of imdb_rating has a very wide spread but closer inspection of the x-axis reveals the lowest rating for any episode is still around a very respectable 6.5 out of 10. The vast majority of the episodes of The Office scored between 7.5 and 9, proving the show was very well regarded by the audiences. The highest ratings, which exceed the stellar mark of 9.5, highlight the heights the show was able to reach. Surrounding that median of roughly 8.25, the IMDb ratings take on a fairly symmetric, normal distribution.

ggplot(data = office_ratings) +
  geom_histogram(mapping = aes(x = total_votes), bins = 20) +
  labs(x = "Total IMDb votes",
       y = "# of episodes",
       title = "Distribution of IMDb vote totals for all Office episodes",
       caption = "Data obtained from raw.githubusercontent.com")

The distribution of total_votes takes on a right-skewed shape as most episodes had from around 1000 to 2500 votes on IMDb, with none below 1000 but on the higher end it gradually tails off until just above 4000 votes. From there a few episodes check in with around 6000 votes, and another at the high mark of nearly 8000. In comparison to the first visualization of this section, it reveals there are far fewer voters than viewers, by a hundred fold in many cases. Even so, it shows The Office had engaged enough viewers to consistently put up a substantial tally of ratings.

Once the temporal component is included later on, it will be relevant to compare how these variables shifted across time.

Relationship between ratings and viewers

To answer the first part of the question asked in the introduction, it is necessary to plot the relationship between imdb_rating and viewers . One might expect episodes with more viewers to be enjoyed more, but it is important to test that. To visualize that, a scatter plot will be used with viewers on the x-axis as the explanatory variable and imdb_rating on the y-axis as the response variable.

ggplot(data = office_ratings, mapping = aes(x = viewers, y = imdb_rating)) +
  geom_point() +
  geom_smooth()  +
  labs(x = "viewers (millions)",
       y = "IMDb rating (out of 10)",
       title = "The Office episodes ratings vs viewers",
       caption = "Data obtained from raw.githubusercontent.com")

cor(office_ratings$viewers, office_ratings$imdb_rating)
## [1] 0.4918702

The scatter plot and trend curve reveal that overall, there is an increase in IMDb ratings for episodes of The Office as the viewer count increased. The correlation coefficient for the variables viewers and imdb_rating is 0.4918702. This positive value supports the relationship of as one increases, so does the other. However, with the coefficient being less than 0.5, it reveals it is not an immensely strong relationship. Visually, that is supported by the scatter plot with various points being rather far from the trend line. This is especially the case for episodes with viewer counts below 5 million. The trend curve shows this distinct area of the plot with a negative slope, indicating that at least for those several episodes, lower view counts were correlated with higher ratings. This coincides with a larger standard error in that region, shown in light gray, before it narrows once the viewership surpasses 5 million and the trend curve begins its upward climb. The outlier of an episode with over 22 million viewers was well received so it supports the positive trend, but the standard error is exceptionally large out there due to the lack of data points.

In an attempt to explain the peculiar trend for the less viewed episodes, it may be useful to alter the aesthetics of the scatter plot and provide some reference to the release of each episode. By color coding the scatter plot points to have a distinct color for each season there may be more insight into this different trend.

ggplot(data = office_ratings, mapping = aes(x = viewers, y = imdb_rating)) +
  geom_point(mapping = aes(color = season)) +
  geom_smooth(mapping = aes(linetype = season<9))  +
  labs(x = "viewers (millions)",
       y = "IMDb rating (out of 10)",
       title = "The Office episodes ratings vs viewers",
       subtitle = "With season denoted by color",
       caption = "Data obtained from raw.githubusercontent.com")

By incorporating the color aesthetic for season to the scatter plot, it reveals nearly all of those episodes with fewer than 5 million viewers came in the final season, season 9. The trend curves on the plot above have different line type aesthetics for whether or not they are from season 9 or earlier. This would suggest by the end of the show’s run it had adopted a new trend in contrast to that of earlier seasons, one that now had less favorable ratings as the viewership increased. Even so, this trend does not work for all of season 9, and the wide band of standard error shows the trend curve is not a perfect fit.

With this new bit of information, it would be logical to follow it up with an investigation of the relationship between viewers and total_votes.

Relationship between Viewers and Total Votes

Although it was already noted in the distribution section that view counts far exceeded vote counts, to this point there has been no examination of the relationship between the two variables viewers and total_votes. It is fair to wonder if when more people watch an episode, is there also an increase in people who leave IMDb reviews? Plotting them on a scatter plot with viewers again as the x-axis and total_votes as the y-axis, along with a correlation calculation, can lend insight into the dynamic between these variables.

ggplot(data = office_ratings, mapping = aes(x = viewers, y = total_votes)) +
  geom_point() +
  geom_smooth()  +
  labs(x = "viewers (millions)",
       y = "total IMDb votes",
       title = "The Office episodes IMDb votes vs viewers",
       caption = "Data obtained from raw.githubusercontent.com")

cor(office_ratings$viewers, office_ratings$total_votes)
## [1] 0.4749562

Here it is seen the relationship between The Office’s viewers and total votes on IMDb has a positive correlation coefficient of 0.4749562. Combined with the visualization of the scatter plot and the trend curve, it is evident there is an overall positive relationship between viewers and total_votes, albeit not an especially strong one. There is an odd dip along the trend curve near the largest cluster of points from approximately 6 to 7.5 million viewers. That portion is the only exception to the generally positive relationship. In attempt to dig deeper into why that may be, the data will again be separated by seasons using the facet grid visualization.

ggplot(data = office_ratings, mapping = aes(x = viewers, y = total_votes)) +
  geom_point() +
  geom_smooth()  +
  labs(x = "viewers (millions)",
       y = "total IMDb votes",
       title = "The Office episodes IMDb votes vs viewers",
       subtitle = "separated by season",
       caption = "Data obtained from raw.githubusercontent.com")  +
  facet_grid(cols = vars(season))

By separating the trend curves by season, it reveals that in most cases the relationship between viewers and total_votes is positive. The most glaring exception is season 1 which features a huge spike on the trend curve yet does not actually have a point up there, Season 3 is also lacking a positive trend, but otherwise the seasons all feature an overall trend of higher vote counts for higher viewer tallies. Although the season breakdown does not fully explain the blip in the initial visualization for the relationship between viewers and total_votes, some of that may be attributed to the standard error. There are a few points for vote totals upwards of 3000 that drag the trend line higher for the range of around 4 to 7 million viewers. The rest of the points in that range are lower in vote total, meaning the potential outliers could very well be the culprit. It is also worthwhile to note that IMDb votes can be cast at any point since an episode’s initial airing, whereas no one new can go back and watch the episode when it aired the first time to grow that number.

Change in The Office’s popularity and appeal over time

A highly relevant point to investigate for this report’s question is the change in popularity over time. Although there is no variable in the dataset called “popularity”, viewers effectively acts as a metric of the show’s popularity. More people watching The Office as it airs means the show is popular. Using a line graph, the visualization for the relationship between air_date as the x-axis and viewers as the y-axis was then further divided with the color aesthetic making clear distinctions between seasons.

ggplot(data = office_ratings, mapping = aes(x = air_date, y = viewers, color = season)) +
  geom_line() +
  geom_point() +
  labs(x = "date of episode airing",
       y = "viewers (millions)",
       title = "Popularity of new The Office episodes over time",
       caption = "Data obtained from raw.githubusercontent.com")

The line graph reveals a noticeable decline in popularity near the end of the show. Season 1 had inconsistent viewer totals, but from season 2 until season 6, the show regularly drew 7.5 million or more viewers. It of course is hard to read too much into the spike in season 5 from the post-Super Bowl timeslot, but that does roughly serve as the peak in show popularity before its decline. The rest of season 5 drew lower viewership than pre-Super Bowl, and season 6, though still popular, did not quite reach the levels of seasons 2-4. By season 7, the decline was in full swing and that continued until season 9’s final episode, the finale of The Office.

ggplot(data = office_ratings, mapping = aes(x = season, y = viewers, color = season)) +
  geom_boxplot() +
  labs(x = "season",
       y = "viewers (millions)",
       title = "Popularity of The Office episodes by season",
       caption = "Data obtained from raw.githubusercontent.com")

Another visualization to observe the change in popularity is through a box plot. This makes the median for viewers within each season much more apparent, and the season 5 outlier is less jarring. Here it can be seen that season 1 as a whole did not have the same popularity as the following seasons, even though the pilot was highly viewed. The decline from season 5 through season 6 is also visible on this visualization.

With the popularity plotted over time, the logical next step is to look at the appeal over the course of the show’s run. Appeal, though similar to popularity, is not exactly the same and is focused more with the viewers’ perception of the show’s quality. As a result, imdb_rating will be used to measure appeal. The better regarded an episode is from IMDb’s voters, the more appealing the episode is. Just like before, the x-axis will be air_date but now the y-axis is imdb_rating.

ggplot(data = office_ratings, mapping = aes(x = air_date, y = imdb_rating, color = season)) +
  geom_line() +
  geom_point() +
  labs(x = "date of episode airing",
       y = "IMDb rating (out of 10)",
       title = "Appeal of new The Office episodes over time",
       caption = "Data obtained from raw.githubusercontent.com")

The line graph of The Office’s appeal over time suggests the show was least appealing to audiences in season 8, although the overall trend across all 9 seasons was that it was high quality from season 2 through season 5 before a decline in appeal began. Seasons 6 and 7 still featured some very appealing episodes, but they were also marred with some less well regarded episodes, indicating a lack of consistency. The final three episodes of the entire show appear to be outliers from the rest of season 9 because they are on par or even exceed the standard set by the show’s golden age of the middle seasons. This could be due to sentimentality as the show concluded.

ggplot(data = office_ratings, mapping = aes(x = season, y = imdb_rating, color = season)) +
  geom_boxplot() +
  labs(x = "season",
       y = "IMDb rating (out of 10)",
       title = "Appeal of The Office episodes by season",
       caption = "Data obtained from raw.githubusercontent.com")

A boxplot of the show’s appeal by season paints an even clearer picture of the decline over time. Although the medians in seasons 6 and 7 remain above 8/10 for imdb_rating, the widening interquartile range (IQR) and far lower first quartile marks show the consistency fall off in comparison to the four prior seasons. Season 7 is especially interesting because it has the largest IQR at nearly a whole rating point. It features one of the most appealing episodes of the entire series, yet the median is almost identical to season 6 and well below seasons 2 through 5. Season 9 is also noteworthy because, as the line graph revealed, the final 3 episodes are well-loved and highly appealing. However, the rest of the season is among the show’s worst. The three highlight episodes are all considered outliers within the context of season 9 because the IQR is small enough that Q3 only grazes 8.0/10. It should be noted that with all this discussion of The Office declining in appeal, even at its worst in seasons 8 and 9, the median rating is still a respectable 7.8 or so. The only reason the decline feels so substantial is because the earlier seasons had set a bar so high.

The popularity and appeal of The Office, as represented by viewers and imdb_rating, both reached low points closer to the series’ end, but they did not progress in completely identical fashion. As seen in the boxplots, the popularity median plummeted more severely between seasons 8 and 9 than the median did for appeal. This may be explained by some audiences giving up on the show after the increasing frequency of unappealing episodes in seasons 6 though 8, while those who stayed around for season 9 did not see it to be any worse than the previous season. Also, at the start of the show, the median appeal climbed steadily across each of the first three seasons, while the popularity took a big jump in season 2 but stayed largely the same for season 3. This could be because the show was still improving in quality and appeal, but had already drawn near to its ceiling as far as consistent popularity was concerned in season 2.

As a final consideration, the trend within each season will be evaluated as part of the overall question.

Conclusion

The Office was and is undoubtedly a beloved show for millions of people. The viewership and ratings of episodes, though not perfectly correlated, followed similar trends and positive relationships over the course of the show. Seasons 2 through 5 marked the peak, before a gradual decline in the next couple seasons and the lowest of the lows in the final two seasons until a brief resurgence at the finale. Even though popularity waned in the later years, that has not stopped The Office from being a staple of the 21st century television landscape.