While the above methodology is quite easy, it can be a bit of a pain at times to create and add the new data frame. Further, you have to tinker more with the labelling to really call out the highlighted data points.
Thanks to Hiroaki Yutani, we now have the gghighlight package which does most of the work for us with a small function call!! Please note that a lot of this code was created by looking at examples on her introduction document.
The new school way is even simplier:
-
Using ggplot2, create a plot with your full data set.
-
Add the gghighlight() function to your plot with the conditions set to identify your subset.
-
Celebrate! This was one less step AND we got labels!
That’s a very cool package. H/T R-Bloggers