[R] Reconfiguring wide frame to long frame

Gabor Grothendieck ggrothendieck at gmail.com
Tue Jul 18 19:12:55 CEST 2006


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 <jesse.canchola.b at bayer.com> 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: Jesse.Canchola.b at Bayer.Com
>
>
>
>
>
> _______________________________________________________________________________________________
>
> 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]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>



More information about the R-help mailing list