[R] grouping data
Ales Ziberna
aleszib at gmail.com
Sat Dec 24 10:32:16 CET 2005
I think you are looking for:
male <- t[,-1][t$sex == "male"]
female <-t[,-1][t$sex == "female"]
----- Original Message -----
From: "Subhabrata" <subhabratapal at sraindia.com>
To: "r-help" <r-help at stat.math.ethz.ch>
Sent: Saturday, December 24, 2005 8:31 AM
Subject: [R] grouping data
Hello R-users/experts,
I am new to R-
I have a simple question:
Let say I have a data set as follows
temp:[file attached]
the data structure is a follows:
sex age
female 28
female 53
female 53
female 36
male 42
male 29
male 43
male 36
male 41
Here we are grouping all male value into male and all female value in to
female
as follows:
t<- read.csv("agesubject1.csv", header = TRUE)
male <- t$age[t$sex == "male"]
female <- t$age[t$sex == "female"]
Now say for example I have a similar data setas follows:
sex age time
female 28 1
female 53 2
female 53 3
female 36 4
male 42 4
male 29 4
male 43 5
male 36 6
male 41 7
Now I want to accept both the values male and female.
Is it possible. i.e. instead of onle age I want age and time both.
So all ages for male and their corresponding time will be loaded.
Thanks for any help
With Regards
Subhabrata Pal
--------------------------------------------------------------------------------
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list