Hi All,

I have constructed two expressions (e1 & e2).  I can see that they are
not identical, but I cannot figure out how they differ.

###############
dat <- mtcars
e1 <- expression(with(data = dat, lm(mpg ~ hp)))
e2 <- as.expression(substitute(with(data = dat, lm(f)), list(f = mpg ~ hp)))

str(e1)
str(e2)
all.equal(e1, e2)
identical(e1, e2) # false

eval(e1)
eval(e2)
################

The context is trying to use a list of formulae to generate several
models from a multiply imputed dataset.  The package I am using (mice)
has methods for with() and that is how I can (easily) get the pooled
results.  Passing the formula directly does not work, so I was trying
to generate the entire call and evaluate it as if I had typed it at
the console, but I am missing something (probably rather silly).

Thanks,

Josh


-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

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

Reply via email to