Thanks all, as a relative newbie to R my use case is taking a dataframe 'd' and subsetting this based on selected rows in a DT table in shiny using the selected rows feature. All of this works fine, I have a large dataframe d and a subset of d called s. I then have a ggplot of points showing all d and want to highlight the selected points from the table which are s in d. I know how to do all of this using DT and ggplot, and for reasons beyond this post I don't want to use the brush feature.
I simply want to have a new column in d which indicates 'color' which will then highlight my points in the ggplot. Hence, I want to set the color of my points c(1,2,3,4,5....) in d based on what is selected in s c(3,5...). So, I'd like 1,2,4 to be steelblue and 3 and 5 to be red.
Here's a simple example
d <- data.frame(Id = c(1,2,3,4,5))
s <- data.frame(Id = c(3,5))
x1 <- if(s$Id %in% d$Id){"red"}else{"steelblue"}
error: the condition has length > 1 and only the first element will be used
x1
[1] "red"
or try
x2 <- ifelse(s$Id %in% d$Id,"red","steelblue")
x2
[1] "red" "red"
Thanks again!