[R] reshaping a data frame

Jim Lemon jim at bitwrit.com.au
Tue Oct 27 01:49:28 CET 2009


On 10/27/2009 07:09 AM, Erin Hodgess wrote:
> Dear R People:
>
> Suppose I have a data.frame, x.df, which has one column and 100 rows.
>
> Sometimes I need to see it as 20 rows and 5 columns, sometimes I need
> to see it as 10 rows with 10 columns.
>
> Is there a quick way to make those transformations, please?
>
>    
matrix(unlist(x),nrow=20)

and maybe

byrow=TRUE

depending upon how you want the values distributed.

Jim




More information about the R-help mailing list