I have the below code, which produces 3 combined graphs which have the same participant ids, each representing a different time period. The respondent answers in each time period. I wonder if there is a way to connect the participant ids in each wave to show individual change over time. I have tried many things but can't work it out. Any help would be greatly appreciated.
combined_data$pidp <- as.character(combined_data$pidp)
subset_data_list <- list()
for (wave_val in unique(combined_data$wave)) {
subset_data_list[[as.character(wave_val)]] <- combined_data[combined_data$wave == wave_val,][1:50,]
}
plot_list <- lapply(names(subset_data_list), function(wave_val) {
ggplot(subset_data_list[[wave_val]], aes(x = ANNUAL_INCOME, y = GENERAL_HAPPINESS, color = pidp)) +
geom_line() +
geom_point(size = 2) +
labs(x = "Income", y = "Happiness") +
theme_minimal() +
ggtitle(paste("Wave", wave_val)) +
theme(legend.position = "none") +
scale_y_continuous(breaks = seq(1, 4, by = 1), limits = c(1, 4))
})
combined_plot <- ggpubr::ggarrange(plotlist = plot_list, ncol = 3)
print(combined_plot)