I would like to add labels for my data points, but would like to add both the x and y value for only the start and end data point. With geom_text, I can only add either x or y for all of my data points. Is there a way for me to achieve what I would like to on my plot?
Some code of my data:
Area <- structure(list(Cumulative.increase = c(14.69, 37.21, 50.72, 51.81, 57.05, 57.98, 72.65, 79.93, 95.82,
97.25, 115.69, 147.69, 155.82, 161.03, 169.9, 185.31, 190.57, 194.82),
Reclaim.date = structure(c(13610, 13722, 13994, 14010, 14154, 14218, 14362, 14426, 14730, 14826, 15082,
15850, 16170, 16378, 16650, 16922, 17370, 17546), class = "Date")),
.Names = c("Cumulative.increase", "Reclaim.date"),
row.names = c(NA, 18L), class = "data.frame")
Here is the code I now have for my plot.
plot1 <- ggplot(Area, aes(x=Reclaim.date, y=Cumulative.increase))+
geom_area() +
geom_text(data = Area, aes(x=Reclaim.date, y=Cumulative.increase,
label = Reclaim.date))
In this case, I would like to include labels of both Date
and Cumulative.increase
in the plot, but only for the first and last data point.
I checked some posts about this, some of them use ifelse to choose their specific points, but as I would like the first and last points, I'm not sure what I should do. Thanks a lot.
Here is what my graph currently looks like, with only the x/y axis (which is the x-axis in this case) and also showing labels for every point but I would like only the first and last point.