great, GREAT, GREAT it just worked..
I don't know why it didn't work yesterday...I had some problem with tidy verse yesterday (Unable to load tidyverse).
I used this code and it worked like magic...
fulldata[,line_color:=ifelse(cum<=20,'black',ifelse(
cum %between% c(20.01,40),'green',ifelse(
cum %between% c(40.01,49),'orange','red')
))]
fulldata %>%
ggplot(aes(date,cum,group=interaction(emp_code,organization),
color=line_color))+
geom_line(alpha=I(.1))+
scale_colour_manual(values=unique(fulldata$line_color))+
geom_hline(yintercept = 50,linetype=3)
Thanks a lot for helping me out. Thank you very much.
There is one more thing I want to know. Is there a way I can relate my alpha level to colors... this is a subset of data. I will have to plot like 800 some people on the graph and I want to highlight only the orange and red part of the line... Is there a way I can dynamically control the alpha level of these lines. Please do reply. I really want to use this code in production as it is much easier to understand.
And just for reference where can I learn how to use this interaction formula in ggplot2. I never knew something like that exists...