I am creating a data.frame inside a function and the set of variables  
to include depends on the current value of other variables.  Is there  
a way to accomplish this in the original assignment?  Or must I first  
create the core data.frame with the variables I always want and then  
use if blocks to add other variables?

Basically, I'm hoping for something like this (which does not work):

newDat <- data.frame(x, y, if(zInclude) z else NULL)

Thanks, Jenny

______________________________________________
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
and provide commented, minimal, self-contained, reproducible code.

Reply via email to