[datatable-help] adding extra layer to ggplot with conditional staement

ilFonta giacomofontanelli76 at gmail.com
Wed Apr 11 18:21:33 CEST 2018


Hi forum
I need to add boxplot layers to my ggplot chart depending on a boolean
condition (TRUE/FALSE).
What's wrong in what I wrote? Thank you

myChart <- ggplot()

if (RotIf == TRUE) {
  myChart = myChart + geom_boxplot(data=fileInRotSubdB,
               outlier.shape = NA,
               aes(x=fileInRotSubdB$acq_date, y=fileInRotSubdB$Mean_dB, 
                   group=fileInRotSubdB$acq_date),
               colour ="black",
               fill="red",
               width=1)} 
 
if (WobIf == TRUE) {
  myChart = myChart + geom_boxplot(data=fileInWobSub,
               outlier.shape = NA,
               aes(x=fileInWobSubdB$acq_date, y=fileInWobSubdB$Mean_dB,
                   group=fileInWobSubdB$acq_date),
               colour ="black",
               fill="pink",
               width=1)}
  
if (BroIf == TRUE) {
  myChart = myChart + geom_boxplot(data=fileInBroSub,
               outlier.shape = NA,
               aes(x=fileInBroSub$acq_date, y=fileInBroSub$Mean_dB,
                   group=fileInBroSub$acq_date),
               colour ="black",
               fill="blue",
               width=1)}



--
Sent from: http://r.789695.n4.nabble.com/datatable-help-f2315188.html


More information about the datatable-help mailing list