[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 10:08:37 CEST 2009


>
> # I tried defining a function like this
> myplot <- function(...)plot(..., pch=19, col=c("blue","red")[treatment])
>
> # So i can call it like this:
> with(mydfr, myplot(Xmeas, Ymeas))
>
> # but:
> Error in plot.xy(xy, type, ...) : object 'treatment' not found
>
basically that is something like calling:

myplot( mydfr$Xmeas, mydfr$Ymeas )

So plot doesn't know that treatment is within mydfr...

changing your function to:

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

should work?

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

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




More information about the R-help mailing list