Skip to content
Back to formatted view

Raw Message

Message-ID: <499D4FD1.7050506@uke.uni-hamburg.de>
Date: 2009-02-19T12:25:53Z
From: Eik Vettorazzi
Subject: table with 3 variables
In-Reply-To: <fff239550902190223mf2f7fe8h2a76ae8d7f667192@mail.gmail.com>

Maybe reshape will help you, but I'm in doubt that your posted desired 
result fits your given data - e.g shouldn't  subject 101 Q3 give "Y"?

xx<-data.frame(Subject=rep(100:101, each=4), 
Quarter=rep(paste("Q",1:4,sep=""),2), Boolean = rep(c("Y","N"),4))
reshape(xx,timevar="Quarter",idvar="Subject",direction="wide",v.names="Boolean")

hth.

Pascal Candolfi schrieb:
> I have the initial matrice:
>
>   
>> *data.frame(Subject=rep(100:101, each=4), Quarter=rep(paste("Q",1:4,
>>     
> sep=""),2), Boolean = rep(c("Y","N"),4))*
>   Subject Quarter Boolean
> 1    100      Q1       Y
> 2    100      Q2       N
> 3    100      Q3       Y
> 4    100      Q4       N
> 5    101      Q1       Y
> 6    101      Q2       N
> 7    101      Q3       Y
> 8    101      Q4       N
> ...
>   
>
> And I would like to group the Subject by Quarter using as a result in the
> table the value of the third variable (Boolean). The final result would
> give:
>
>   Subjet Q1 Q2 Q3 Q4
> 1    100  Y  Y  Y  Y
> 2    101  N  N  N  N
> ...
>   
>
> I started using the *table(Subject, Quarter)* but can't find a way to
> correspond the Boolean information in the table....
> Thanks in advance for the ideas...
>
> Pascal Candolfi
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>   

-- 
Eik Vettorazzi
Institut f?r Medizinische Biometrie und Epidemiologie
Universit?tsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/42803-8243
F ++49/40/42803-7790