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@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

______________________________________________
R-help@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.

Reply via email to