[R] How to convert a matrix to a dataframe and makes its first row be the column name

yabado alexhsi1123 at hotmail.com
Fri Jul 24 20:56:58 CEST 2009


Hi

I want to convert a matrix to a dataframe.

The matrix is like this

Site   A     B     C     D

X       1     2     3     4
   
Y       5     6     7     8

Z       9     10    11   12


The converted dataframe need to have the first row as column names
and the values of each column (1, 2, 3, 4; ......12;) be numeric, not
factors.

I used data.frame(), but it gave me auto-assigned column names (like X1, X2,
X3, X4)  
and put the alphabet and numbers together as factors of each column. 

Is there a way to correct it?

Thank you
  
-- 
View this message in context: http://www.nabble.com/How-to-convert-a-matrix-to-a-dataframe-and-makes-its-first-row-be-the-column-name-tp24650062p24650062.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list