"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

-- 
Douglas Bates                            [EMAIL PROTECTED]
Statistics Department                    608/262-2598
University of Wisconsin - Madison        http://www.stat.wisc.edu/~bates/

______________________________________________
[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

Reply via email to