Convert first column in data.frame to row index

Viewed 32165

I have a data.frame:

     target_id sample1 sample10 sample100 sample101 sample102 sample103
1: ENST00000000233       9        0   3499.51         0         0         0
2: ENST00000000412       0        0      0.00         0         0         0
3: ENST00000000442       0        0      0.00         0         0         0
4: ENST00000001008       0        0      0.00         0         0         0
5: ENST00000001146       0        0      0.00         0         0         0
6: ENST00000002125       0        0      0.00         0         0         0

I would like to convert it to another data.frame, where $target_id will be a row name. Specifically, I want to perform clustering on numerical data (from sample columns) and then be able to access their gene entities (for example: ENST00000000233)

                sample1 sample10 sample100 sample101 sample102 sample103
ENST00000000233       9        0   3499.51         0         0         0
ENST00000000412       0        0      0.00         0         0         0
ENST00000000442       0        0      0.00         0         0         0
ENST00000001008       0        0      0.00         0         0         0
ENST00000001146       0        0      0.00         0         0         0
ENST00000002125       0        0      0.00         0         0         0

Is it possible to create such data.frame in R?

3 Answers
Related