Apologies, it was as.formula(),

I have since found out that if you pass to cast() the formula as a 
character string "days ~ variable" it works.




Gavin Simpson <gavin.simpson@ucl.ac.uk> 
04/07/09 03:40 PM
Please respond to
gavin.simpson@ucl.ac.uk


To
ryan.sheftel@malbecpartners.com
cc
r-help@r-project.org
Subject
Re: [R] Using as.formula() with the reshape package cast





On Tue, 2009-04-07 at 09:47 -0400, ryan.sheftel@malbecpartners.com
wrote:
> I am trying to use the "cast" function from the reshape package, where 
the 
> formula is not passed in directly, but as the result of the as.formula() 

> function. 
> 
> Using reshape v. 0.7.2 
> 
> I am able to properly melt() by data with: 
> 
> > molten <- melt(x, id=1:2) 
> 
> then I can properly cast with this: 
> 
> > cast(molten, days ~ variable) 
> 
> but if I try 
> 
> > cast(molten, as.function("days ~ variable")) 
                    ^^^^^^^^^

Did you really use as.function not as.formula as you claim or is this a
typo in composing this posting? If this is what you typed, that may well
be the source of the error.

HTH

G

> 
> if returns the error: 
> 
> Error in check_formula(formula, varnames) : 
>         Formula contains variables not in list of known variables 
> 
> I am not sure if the problem is with cast or as.formula() 
> 
> I did confirm that: 
> 
> > x <- days ~ variable 
> 
> > y <- as.formula("days ~ variable") 
> 
> > x==y 
> TRUE
> 
> 
>                [[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



	[[alternative HTML version deleted]]


