I read someone had a similar question (ggplot2 and facet_grid : add highest value for each plot) but I still couldn't solve my problem.
Take this for example:
data.frame(x=rnorm(100),y=rnorm(100),z=rep(c("A","B"))) %>% ggplot(aes(x,y)) + geom_point() + facet_wrap(~z)
I want to label only the max y-value point in each plot. I wanted to use + geom_label_repel(aes(label=y))
but I ended up labelling all points.
I also tried with + geom_label(data=.[.$y==max(.$y),], aes(label=y))
where I thought .
should be a placeholder for the argument left of the pipe operator but doing it this way does not work.
Quirky note: I also want to do this without assigning the data frame to a variable in the global environment so I'm using the pipe operator. Can we do this without assigning any variables?