[R] need help creating means table

David White dwhite at ling.ohio-state.edu
Mon Sep 24 20:27:13 CEST 2001


Many thanks Dr. Ripley and Dr. Dalgaard,

Your soluttions worked out very well. I have had great difficulty
understanding the behavior of by and and the various *apply.

Now I would like to plot the new mean data. I see that xx.mean[[i]] will
give me access to a set of the mean numeric results, but I don't know how
to access the condition indices, that is if

> xx.mean[[2]]

         Peak      proppeak        Median      skewness         slope
 3.309961e+03  1.272084e-01  6.852911e+03 -3.228079e-01 -1.820004e-03

what are the levels of subjs, cons and vowels associated with those mean
values?

TIA,

D

S. David White
sdavidwhite at bigfoot.com
Columbus, Ohio

On Mon, 24 Sep 2001, Prof Brian D Ripley wrote:

%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