Beginner: highlighting categorical data

Hi R users,
I'm thinking is it possible to use gghighlight to highlight categorical data?
Here's my hypothetical example:

Lets say I have a list of employees that are going to be promoted: It's JD and AA. I want to highlight these guys on the graph, while keeping everything I have going on.

I'm still quite new to R studio so any advice is highly appreciated!

Hello, Thanks for joining the forum.
Of course, there are a times when images are useful, particularly for sharing a problematic chart, however, the best way to communicate code is as code, so please repost your code by copy and pasting it.
The forum can format your code as code if you use triple back ticks on a seperate line before (and after) your code

```
example code
```

back to normal writing

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

Sure thing! Thank you for the tip, you're right that makes it much easier.
Here's the code:

library(tidyverse)
library(ggforce)
library(ggplot2)
employee <- c('JD','PG','JH', 'JJ','AA', 'BB')
salary <- c(21000, 23400, 26800, 27000,21500, 25500)
employ.data <- data.frame(employee, salary)

ggplot(data = employ.data) +
  aes(y = salary, x= "Employees")+ 
  ggforce::geom_sina(col=ifelse(employ.data$salary>=22000, rgb(255,0,0,120,maxColorValue=255),rgb(0,0,0,100,maxColorValue=255))) +coord_flip()+
  geom_abline(intercept=22000,slope = 0,lty=2)+
  theme_minimal()+theme(axis.line = element_line(colour = "black", size = 0.5, 
                                                 linetype = "solid"))+
  scale_y_continuous(breaks=seq(20000,25000,28000))+ labs(y="Salary")

I guess I might have to create a separate variable that answers the question Is the employee on the 'promotion list' and maybe use that?