[R] groupe averages error
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri Nov 24 12:30:07 CET 2000
> From: "Charles Raux" <Charles.Raux at let.ish-lyon.cnrs.fr>
> To: <r-help at stat.math.ethz.ch>
> Date: Fri, 24 Nov 2000 10:41:29 +0100
> Subject: [R] groupe averages error
> I want to get subsets averaged on numeric variables number 5:13 but I
> get the error below that I cannot understand.
> > is.factor(dat$Statut)
> [1] TRUE
> > s<-ave(dat[,5:13],dat$Statut)
> Error in [<-.data.frame(*tmp*, , value = if (n) { :
> Argument "i" is missing, with no default
>
Nor can I, but then I don't have your data, nor the result of traceback()
(which can be *very* helpful). However, ave() does not apply to
dataframes, and its help page says
Usage:
ave(x, ..., FUN = mean)
Arguments:
x: A numeric.
I think you probably need to use by()
> dat <- as.data.frame(matrix(rnorm(1300), 100))
> dat$Statut <- factor((0:99)%/%10)
> by(dat[,5:13],dat$Statut, function(x) sapply(x, mean))
for example.
--
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