Line Plots

There are many variables that change over time. Line plots are useful in visualizing data points across time.

library(datasets)
library(ggplot2)
library(ggthemr)
# Converting the data to time series 
data = as.data.frame(AirPassengers)
data$months = seq(as.Date("1949-01-01"), by = "month", length.out = nrow(data))

colnames(data) <- c("passengers", "months")
head(data)
A data.frame: 6 × 2
passengersmonths
<dbl><date>
11121949-01-01
21181949-02-01
31321949-03-01
41291949-04-01
51211949-05-01
61351949-06-01
ggthemr('grape')

base = ggplot(data = data, aes( x = months , y = passengers)) + 
       geom_line() +
       labs( title = "Airline Passengers by Month")
base