"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" Are you sure that this is the final result you want ? You could use the reshape package (and not reshape function) : library(reshape) truc <- data.frame(Subject=rep(100:101, each=4), Quarter=rep(paste("Q",1:4,sep=""),2), Boolean = rep(c("Y","N"),4)) mtruc <- melt(truc, id = c("Subject", "Quarter")) cast(mtruc, Subject ~ Quarter) Final result : Subject Q1 Q2 Q3 Q4 1 100 Y N Y N 2 101 Y N Y N 2009/2/19 Pascal Candolfi <pcando...@gmail.com> > 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. > [[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.