> 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...
remko ------------------------------------------------- Remko Duursma Post-Doctoral Fellow Centre for Plants and the Environment University of Western Sydney Hawkesbury Campus Richmond NSW 2753 Dept of Biological Science Macquarie University North Ryde NSW 2109 Australia Mobile: +61 (0)422 096908 www.remkoduursma.com On Mon, Sep 14, 2009 at 6:08 PM, Polwart Calum (County Durham and Darlington NHS Foundation Trust) <calum.polw...@nhs.net> wrote: >> >> # 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}} > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.