[R] How to set default plotting colors by treatment?

Polwart Calum (County Durham and Darlington NHS Foundation Trust) calum.polwart at nhs.net
Mon Sep 14 13:53:36 CEST 2009


>> col=c("blue","red")mydfr$[treatment]
>
> Yes, but I would like to use the function for lots of other dataframes
> as well, so embedding 'mydfr' in the function is not the ideal
> solution...

In that case I'd try something like:

 myplot <- function(..., tmnt) {
 plot(...,
       pch=19,
       col=c("blue","red")[tmnt]
      )
 }

with(mydfr, myplot(Xmeas, Ymeas, tmnt=treatment))

That seems to work... - basically you just need to pass treatment in the function call...




********************************************************************************************************************

This message may contain confidential information. If yo...{{dropped:21}}




More information about the R-help mailing list