Try: > mydata2 <- with(mydata, data.frame(Var1 = rep(Var1, Count), + Response=rep(Response, Count) ) + ) > mydata2 Var1 Response 1 A 1 2 A 2 3 A 2 4 B 6 5 B 6 6 B 6 7 A 7 8 A 7 9 A 7
Hope this helps, ________________________________________ From: [EMAIL PROTECTED] [EMAIL PROTECTED] On Behalf Of Juliet Hannah [EMAIL PROTECTED] Sent: Monday, October 13, 2008 8:57 PM To: r-help@r-project.org Subject: [R] command to expand a cross classification / contingency table For data such as mydata <- read.table(textConnection("Var1 Response Count A 1 1 A 2 2 B 6 3 A 7 3"),header=TRUE) closeAllConnections() is there a command to transform this data so that there is a single observation per row? A 1 A 2 A 2 B 6 B 6 B 6 A 7 A 7 A 7 Thanks, Juliet ______________________________________________ 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. ______________________________________________ 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.