Income Changes by Social Class

This plot showcases the changes in incomes for different social classes over time.

library(plotly)
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
# Sample data for different social classes' incomes over time
time <- seq(1, 10)
lower_class_income <- time * 2000
middle_class_income <- time * 5000
upper_class_income <- time * 10000

data <- data.frame(Time = time, LowerClass = lower_class_income, MiddleClass = middle_class_income, UpperClass = upper_class_income)

# Convert to long format for Plotly
data_long <- reshape2::melt(data, id.vars = "Time")

# Create the Plotly plot
plot_ly(data_long, x = ~Time, y = ~value, color = ~variable, type = 'scatter', mode = 'lines') %>%
  layout(title = "Income Changes by Social Class",
         xaxis = list(title = "Time"),
         yaxis = list(title = "Income"))

In this plot, you can clearly see the different trends in income changes for lower, middle, and upper social classes.