newdf<-data.frame(k1=rep(row.names(foo),ncol(foo)),stack(foo)) --- On Fri, 1/2/13, Gundala Viswanath <gunda...@gmail.com> wrote:
From: Gundala Viswanath <gunda...@gmail.com> Subject: [R] Transforming 4x3 data frame into 2 column df in R To: "r-h...@stat.math.ethz.ch" <r-h...@stat.math.ethz.ch> Date: Friday, 1 February, 2013, 11:30 AM I have the following data frame: > foo w x y z n 1.51550092 1.4337572 1.2791624 1.1771230 q 0.09977303 0.8173761 1.6123402 0.1510737 r 1.17083866 1.2469347 0.8712135 0.8488029 What I want to do is to change it into : > newdf 1 n w 1.51550092 2 q w 0.09977303 3 r w 1.17083866 4 n x 1.43375725 5 q x 0.81737606 6 r x 1.24693468 7 n y 1.27916241 8 q y 1.61234016 9 r y 0.87121353 10 n z 1.17712302 11 q z 0.15107369 12 r z 0.84880292 Whtat's the way to do it? - G.V. [[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.