[R] grouping data

Sumanta Basak sumantab at ambaresearch.com
Mon Dec 26 10:45:53 CET 2005


Hi Subhabrata,

I'm not totally sure what you are looking for. You can try to separate
both male and female category by creating subset.

t<- read.csv ("agesubject1.csv", header = TRUE)

t.male<-subset(t,sex=="male")
t.female<-subset(t,sex="female")

See whether you want this??

Thanks & Regards,
SUMANTA BASAK.


-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Subhabrata
Sent: Saturday, December 24, 2005 1:02 PM
To: r-help
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



-------------------------------------------------------------------------------------------------------------------
This e-mail may contain confidential and/or privileged infor...{{dropped}}




More information about the R-help mailing list