[R] a question of substitute

Adrian Dusa dusa.adrian at gmail.com
Tue Jan 9 14:54:35 CET 2007


On Tuesday 09 January 2007 15:41, Prof Brian Ripley wrote:
> oneway.test expects a literal formula, not a variable containing a
> formula.  The help page says
>
>   formula: a formula of the form 'lhs ~ rhs' where 'lhs' gives the
>            sample values and 'rhs' the corresponding groups.
>
> Furthermore, if you had
>
> foo.2 <- function() oneway.test(value ~ group)
>
> it would still not work, as
>
>      data: an optional matrix or data frame (or similar: see
>            'model.frame') containing the variables in the formula
>            'formula'.  By default the variables are taken from
>            'environment(formula)'.
>
> I could show you several complicated workarounds, but why do you want to
> do this?

Thank you for your reply. The data argument was exactly the next problem I 
faced. My workaround involves checking if(missing(data)) then uses different 
calls to oneway.test(). I am certainly interested in other solutions, this 
one is indeed limited.

I do this for the students in the anova class, checking first the homogeneity 
of variances with fligner.test(), printing the p.value and based on that 
changing the var.equal argument in the oneway.test()
It's just for convenience, but they do like having it all-in-one.

Best regards,
Adrian

-- 
Adrian Dusa
Romanian Social Data Archive
1, Schitu Magureanu Bd
050025 Bucharest sector 5
Romania
Tel./Fax: +40 21 3126618 \
          +40 21 3120210 / int.101



More information about the R-help mailing list