Douglas Bates <[EMAIL PROTECTED]> writes:
> "David A. van Leeuwen" <[EMAIL PROTECTED]> writes:
>
> > Hi,
> >
> > i am working with large data frames with many dependend variables. I
> > want to write some functions that will allow me to quickly select
> > variables from the frame and plot them in various colors depending on
> > factor columns, possibly selecting rows according to factor
> > conditions. In order to do this in a nice function, i need to
> > understand how to work with a column name in the body of a
> > function. To simplify my problem, how do i write a function with a
> > body like
> >
> >
> > scatter.plot <- function (data, x, y) {
> > plot(data$x, data$y)
> > }
>
> Use
> plot(data[[x]], data[[y]])
> instead
The plot labels won't come out right then. I think David was
looking for something like
function(data, x, y)
eval(substitute(plot(x,y)), data)
or to be able to pass names:
function(data, x, y)
eval(substitute(plot(x,y),list(x=as.name(x), y=as.name(y))), data)
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907
______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html