I'm very new to R and I'm looking to highlight certain groups in my plot using gghighlight. For example, I want to highlight in red only groups 16 and 32 while leaving the rest of the lines in gray. My current code and output are below. I can't seem to highlight specific groups, I can only add color to all lines. I've tried gghighlight(grp==16) to try and highlight 16 but it says "Tried to calculate with group_by(), but the calculation failed".
library(readxl)
library(ggplot2)
library(gghighlight)
guidelines <- read_excel("data.xlsx", sheet=1)
guidelines$step <- factor(guidelines$step, levels=c("First", "Highest", "Final"))
map <- ggplot(guidelines,
aes(x = step, y = type, group = grp, color = factor(grp))) +
scale_color_hue(l=45)+
geom_line(linetype = 1) +
geom_line(position=position_jitter(w=0, h=0.05))
map + scale_y_continuous(breaks = c(1,2,3,4))
map + scale_y_continuous(breaks = c(1,2,3,4), labels = c("Method 1", "Method 2"
, "Method 3", "Method 4"))