ginal Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of John Sorkin
Sent: Wednesday, January 13, 2010 12:11 PM
To: r-help@r-project.org
Subject: [R] Applying function to parts of a matrix based on a factor
R 2.9
Windows XP
I have a matrix, Data, whi
try this:
with(Data, tapply(Age, Sex, mean))
I hope it helps.
Best,
Dimitris
John Sorkin wrote:
R 2.9
Windows XP
I have a matrix, Data, which contains a factor Sex and a continuous variable
Age.
I want to get mean age by sex. I know I can do this with two statements,
mean(Data["Age,Data[,
with(yourdataframe, tapply(age,sex,mean))
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of John Sorkin
Sent: Wednesday, January 13, 2010 12:11 PM
To: r-help@r-project.org
Subject: [R] Applying function to parts of a matrix based on
R 2.9
Windows XP
I have a matrix, Data, which contains a factor Sex and a continuous variable
Age.
I want to get mean age by sex. I know I can do this with two statements,
mean(Data["Age,Data[,"Sex"]=="Male") and
mean(Data["Age,Data[,"Sex"]=="Female")
I know this can be done in a single comman
4 matches
Mail list logo