Dear R-users, This should be simple but still eludes me:
Given the following tmp<-as.data.frame(matrix(c(44, 10, "abc", 1, 44, 10, "def", 1, 44, 12, "abc", 2), 3, 4, byrow=T)) I want to expand the data to the following form: V1 V2 V3 V4 1 44 10 abc 1 2 44 10 def 1 3 44 12 abc 1 4 44 12 abc 1 The last row of the original df was duplicated the row by the number in the 4th column (which could be expendable being all ones) I clumsily tried a few variants of a loop but I am not making any progress. Any hints would be greatly appreciated. for (i in 1:3){ rbind(rep(tmp[i,], temp[i,4]) } -- View this message in context: http://r.789695.n4.nabble.com/Simple-but-elusive-expand-back-from-counts-tp3415727p3415727.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.