[R] Using data=x or subset=y in user-defined functions

From: Manuel Morales <Manuel.A.Morales_at_williams.edu>
Date: Thu 08 Jun 2006 - 06:01:36 EST

Dear list members,

In some of my functions, I attach the data internally to allow subset commands or to specify a data frame. This works well except for cases where there is a "masking" conflict (which returns a warning). I see some alternative listed in ?attach, but I'm not sure which of them do what I'd like. Any suggestions?

Below is how I've been setting up my functions:

eg.function <- function(x, data=NULL, subset=NULL, ...) {

# Set up environment
if(!is.null(subset)) {


subset = NULL  

# Function body here
output <- x



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jun 08 06:14:48 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 08 Jun 2006 - 08:10:47 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.