I need to add value labels for data points on two separate lines that are generated from a data frame in R using ggplot2. The following is the code snippet that I am using:
DataFrame = data.frame(Amount = c(results$Costs,
results$TotalPoC),
Legend = rep(c("Cost as % of initial costs",
"Revenue as % of cost"),
each = nrow(results)),
Year = rep(0:5,2))
p <- ggplot(ResultsCR, aes(x=Year, y=Amount, group=Legend)) +
geom_line(aes(linetype=Legend))+
geom_point(aes(shape=Legend))+
geom_text(aes(label=Amount))+
theme_classic(base_size = 15) +
ggtitle("Hospital Costs and Revenues")
print(p)
However, the graph is only displaying the labels on the second line, i.e. the one corresponding to the Legend "Revenue as % of cost". How can I generate labels for data points on all lines generated from the same data frame in ggplot2?