# New dataset with an additional column for line types
data2 <- data.frame(
Year = rep(2010:2020, 3),
Value = c(12, 15, 18, 22, 25, 30, 35, 40, 43, 48, 50,
10, 13, 17, 20, 24, 28, 32, 37, 41, 44, 49,
17, 20, 22, 27, 29, 34, 39, 42, 47, 51, 55),
Category = rep(c("X", "Y", "Z"), each = 11),
LineType = rep(c("solid", "dashed", "dotted"), each = 11)
)
plot2 <- ggplot(data2, aes(x = Year, y = Value, color = Category, linetype = LineType)) +
geom_line(size = 1.2) +
geom_point(data = data2 %>% group_by(Category) %>% filter(Year == max(Year)), size = 4) +
theme_minimal() +
labs(title = "Line Plot with Different Line Types and End Points", x = "Year", y = "Value") +
scale_color_manual(values = c("X" = "purple", "Y" = "orange", "Z" = "brown"))
print(plot2)