[R] need help creating means table
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Mon Sep 24 20:07:49 CEST 2001
On Mon, 24 Sep 2001, David White wrote:
> Peter Delgaard wrote:
> %
> %How about
> %
> %nums <- sapply(xx, is.numeric)
> %by(xx[nums], list(subjs, cons, vowels), mean)
> %
> %?
> %
>
> Thanks Peter, that gets me around the error message, but it return only
> one value per subjs x vowels x cons combination, I need a separate mean
> for each of the fix numeric columns.
That's what mean does on a data frame. You want something like
by(xx[nums], list(subjs, cons, vowels), function(x) sapply(x, mean))
>
> Best,
>
> D
>
> S. David White
> sdavidwhite at bigfoot.com
> Columbus, Ohio
>
> On 24 Sep 2001, Peter Dalgaard BSA wrote:
>
> %David White <dwhite at ling.ohio-state.edu> writes:
> %
> %> Hello,
> %>
> %> I have been trying to use by to create a means table, but receive the
> %> error " by(xx, list(subjs, cons, vowels), mean)
> %> Error in Summary.data.frame(..., na.rm = na.rm) :
> %> only defined on a data frame with all numeric or complex
> %> variables" when the data frame consists of three factor columns (subjs,
> %> cons and vowels) and 5 numeric data columns.
> %>
> %> The output I'm looking for is a simple mean for each of the numeric
> %> columns by the independent variables subjs, vowel, consonant.
> %>
> %> Thanks for you advice,
> %--
> % O__ ---- Peter Dalgaard Blegdamsvej 3
> % c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
> % (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
> %~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
> %
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
--
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