[R] R: one bananna aov() question
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Sat Apr 1 08:59:48 CEST 2000
On Fri, 31 Mar 2000, Pete Hurd wrote:
> I'm trying to do an
> anova on data in data.set, dependent variable is a column
> named "dep.var", grouping variable is in a column called "indep.var", and
> is.factor(indep.var) is TRUE...
> why can't I just do aov(dep.var ~ indep.var, data = data.set)?
>
> What have I done to deserve this?! What gives? Am I missing something
> totlly obvious?
I think so. In your example it is not obvious what is a factor. I get
resids.dat <- read.table("resids") # from output as given
aov(aggr.resid ~ factor(indiv.code), data = resids.dat)
> summary(.Last.value)
Df Sum Sq Mean Sq F value Pr(>F)
factor(indiv.code) 25 401.24 16.05 6.5163 4.763e-14
Residuals 150 369.45 2.46
In aov(y ~ x) you should expect x to be a factor and y to be continuous.
I think you have made y (aggr.resid) into a factor. That you tried
both ways round suggests you are a little confused, and
> aov(factor(aggr.resid) ~ factor(indiv.code), data = resids.dat)
does give the messages you quoted.
> R-base-1.0.0-1, linux RH 6.1.
Could you just tell us the version of R? Who packaged it as an RPM is
not so relevant.
>
> ---------------------------------------------------------------------
>
> > aov(aggr.resid ~ indiv.code, data = resids.dat)
> Error in lm.fit(x, y, offset = offset) : NA/NaN/Inf in foreign function
> call (arg 4)
> In addition: Warning message:
> "-" not meaningful for factors in: Ops.factor(y, offset)
> > aov(indiv.code ~ aggr.resid, data = resids.dat)
> Error in lm.fit(x, y, offset = offset) : NA/NaN/Inf in foreign function
> call (arg 4)
> In addition: Warning message:
> "-" not meaningful for factors in: Ops.factor(y, offset)
[ ... listing of data ]
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list