lD
> Sent: 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
> ta
46/51/57|
46/48/52| 49/54/60| F=2.9 d.f.=3,16 P=0.068 |
+--+--+--+--+--+--++
> Date: Sat, 26 Jun 2010 21:48:05 -0700
> From: raoul.t.dso...@gmail.com
> To: r-h
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
--
Vi
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
College
You could try the remix function in remix package.
David
Le 27 juin 2010 à 06:48, RaoulD 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
> it.
>
> Regards,
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:
http://r.789695.n4.nabble.com/Calculating-Summaries-for-each-
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:
http://r.789695.n4.nabble.com/Calculating-Summaries-for-each-level-of-a-Catego
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
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
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
corey.sp
10 matches
Mail list logo