[R] reshape a data frame

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.be
Mon Aug 21 17:05:03 CEST 2006


maybe something like the following:

mdf <- data.frame(COL1 = rnorm(20))
mdf
as.data.frame(matrix(mdf$COL1, ncol = 2, byrow = TRUE))


I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "P. Stencel" <peterstencel at yahoo.de>
To: <r-help at stat.math.ethz.ch>
Sent: Monday, August 21, 2006 4:57 PM
Subject: [R] reshape a data frame


> Dear R-helpers,
>
> I am trying to reshape a data frame which consists of only one 
> column and of
> several thousand rows. My purpose is to select every second element 
> (row) of
> the data frame and to create a second column with these elements.
>
> The data frame looks like this:
>
> COL1
> 23.190779669
> 74.659456135
> 74.019522268
> 27.099553199
> 50.02049443
> 76.518205961
> 75.924447203
> 75.774890661
> ...
>
> Could anybody give me a piece of advice how to proceed? Are there 
> any
> commands to solve this problem?
>
> ______________________________________________
> 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.
> 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



More information about the R-help mailing list