Thanks, Gabor. Since the data stacking components are independent, that didn't matter much but I am grateful for your follow-up code to match the desired output specifically.
Regards, Jesse "Gabor Grothendieck" <[EMAIL PROTECTED]> 07/18/2006 10:36 AM To "Jesse Albert Canchola" <[EMAIL PROTECTED]> cc [email protected] Subject Re: [R] Reconfiguring wide frame to long frame Sorry, in looking at this again my previous code did not give the same ordering you indicated. Instead using the same DF try this: rbind(as.matrix(DF[,1:2]), as.matrix(DF[,3:4])) Both this and the last piece of code produce matrices so use as.data.frame if you want a data frame. On 7/18/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Try this: > > # set up test data > Lines <- "ID meas ID.1 meas.1 > 1 1.1 3 1.2 > 2 2.1 4 2.2 > " > DF <- read.table(textConnection(Lines), header = TRUE) > > # reshape > matrix(t(DF), nc = 2, byrow = TRUE, dimnames = list(NULL, colnames(DF)[1:2])) > > > On 7/18/06, Jesse Albert Canchola <[EMAIL PROTECTED]> wrote: > > Greetings, fellow R'ers. > > > > How can I get this frame in R: > > > > ID meas ID.1 meas.1 > > 1 1.1 3 1.2 > > 2 2.1 4 2.2 > > > > to look like this (stacking): > > > > ID meas > > 1 1.1 > > 2 2.1 > > 3 1.2 > > 4 2.2 > > > > It's not really the reshape function (or is it?) because we can consider > > the additional columns, viz., ID.1 and meas.1, as independent of ID and > > meas so it is basically a stacking problem (no longitudinal component). I > > can't seem to find a good example to do this in the docs. Thanks for your > > help. > > > > Regards, > > Jesse > > > > > > > > > > > > > > > > > > Jesse A. Canchola > > Biostatistician III > > Bayer Healthcare > > 725 Potter St. > > Berkeley, CA 94710 > > P: 510.705.5855 > > F: 510.705.5718 > > E: [EMAIL PROTECTED] > > > > > > > > > > > > _______________________________________________________________________________________________ > > > > The information contained in this e-mail is for the exclusive use of the intended recipient(s) and may be confidential, proprietary, and/or legally privileged. Inadvertent disclosure of this message does not constitute a waiver of any privilege. If you receive this message in error, please do not directly or indirectly use, print, copy, forward, or disclose any part of this message. Please also delete this e-mail and all copies and notify the sender. Thank you. > > > > For alternate languages please go to http://bayerdisclaimer.bayerweb.com > > _______________________________________________________________________________________________ > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > [email protected] 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. > > > ______________________________________________ [email protected] 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.
