: Saturday, June 26, 2010 10:47 PM
To: r-help@r-project.org
Subject: Re: [R] Calculating Summaries for each level of a Categorical
variable
Hi Corey,
Thanks so much for this. However, I get this error for tapply - Error
in
tapply(RT, RT$R, fun=WA):
arguments must have same length. Any
Hi Corey,
Thanks so much for this. However, I get this error for tapply - Error in
tapply(RT, RT$R, fun=WA):
arguments must have same length. Any idea how to get around this?
Thanks again,
Raoul
--
View this message in context:
Hi Christos,
Thanks for this. I had a look at Summary.Forumla in the Hmisc package and it
is extremely complicated for me. Still trying to decipher how I could use
it.
Regards,
Raoul
--
View this message in context:
You could try the remix function in remix package.
David
Le 27 juin 2010 à 06:48, RaoulD raoul.t.dso...@gmail.com a écrit :
Hi Christos,
Thanks for this. I had a look at Summary.Forumla in the Hmisc
package and it
is extremely complicated for me. Still trying to decipher how I
could use
the variable you want to analyze (first argument to tapply) and the
variable you want to analyze by (the factor, second arg to tapply)
both must have the same number of rows, that' s how I read this.
CS
Corey Sparks
Assistant Professor
Department of Demography and Organization Studies
I'd suggest using the functions within the Hmisc and plyr packages:
library(Hmisc); library(plyr)
df=data.frame(v1=rnorm(10), v2=rnorm(10),
wt=sample(1:5,rep=T),sex=rep(0:1,each=5)); df
ddply(df,~sex,summarise,v1.avg=wtd.mean(v1,wt),v2.avg=wtd.mean(v2,wt))
hope this helps, david freedman
--
|
+--+--+--+--+--+--++
Date: Sat, 26 Jun 2010 21:48:05 -0700
From: raoul.t.dso...@gmail.com
To: r-help@r-project.org
Subject: Re: [R] Calculating Summaries for each level of a Categorical
variable
Hi Christos
Did you try tapply?
?tapply
tapply(RT, RT$R, fun=WA)
or something like that
-
Corey Sparks, PhD
Assistant Professor
Department of Demography and Organization Studies
University of Texas at San Antonio
501 West Durango Blvd
Monterey Building 2.270C
San Antonio, TX 78207
210-458-3166
Hi,
I have a dataset which has a categorical variable R,a count variable C
(integer) and 4 or more numeric variables (A,T,W,H - integers) containing
measures for R. I would like to summarize each level of the variable R by
the average for A,T,W and H.
I have written a function to calculate
Look at the summary.formula function inside package Hmisc
Christos
Date: Sat, 26 Jun 2010 05:17:34 -0700
From: raoul.t.dso...@gmail.com
To: r-help@r-project.org
Subject: [R] Calculating Summaries for each level of a Categorical variable
Hi,
I have a dataset which has a categorical
10 matches
Mail list logo