[R] reshape a matrix

Rolf Turner rolf.turner at xtra.co.nz
Sun Aug 21 02:13:47 CEST 2011


On 21/08/11 03:04, Wendy wrote:
> Hi all,
>
> I have a data.frame like following
>
> A<-c('d0','d0','d1','d1','d2','d2')
> B<-rep(c('control','sample'),3)
> C<-c(rep(100000,2),200,300,400,500)
> dataframe<-data.frame(A,B,C)
>
> I want to reshape the matrix, so the matrix with 'd0', 'd1' and 'd2' in rows
> and 'control' and 'sample' in columns. Is there a function for doing this
> easily?

Your question has been answered .... But if you remember that a *matrix*
and a *data frame* are ***NOT*** the same thing, you'll get into a lot less
trouble.  Why do you think there are two *different* terms for these sorts
of object if they are the same thing?  Psigh!!!

     cheers,

         Rolf Turner



More information about the R-help mailing list