[R] dataframe conversion
Uwe Ligges
ligges at statistik.uni-dortmund.de
Tue Nov 1 17:53:57 CET 2005
Pieter Provoost wrote:
> The data structures in R are still very puzzling to me. Can anyone tell
> me how I can easily convert these two dataframes to one single dataframe
> with two columns (mean and sd) with 7 rows?
>
> > meanprofile
> V1 V2 V3 V4 V5 V6 V7
> 2292.001 2178.620 1654.310 1784.004 1160.052 1142.061 1046.675
> > sdprofile
> V1 V2 V3 V4 V5 V6 V7
> 310.6714 347.2072 197.2464 532.3916 161.2955 227.3634 108.5017
This is quite an unusual task, because you won't have data structure in
a data.frame most of the times. In particular, you cannot make a row
from a data.frame to a column generally.
In this case, we just convert the data.frame to matrix. I think most
easily you can write:
dat <- t(rbind(meanprofile, sdprofile))
colnames(dat) <- c("meanprofile", "sdprofile")
Uwe Ligges
> Thanks!
> Pieter
>
> ______________________________________________
> 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
More information about the R-help
mailing list