0

I need to rename the rows of a dataset with a the value of a defined column:

   a  b  c 
1  d  e  f
2  g  h  i
3  j  k  l   

has to become

   b  c  
d  e  f
g  h  i
j  k  l
Jua'
  • 51
  • 3
  • 9
  • 1
    That's generally a bad idea. It's better to work with column rather row names. Why do you *need* this? – David Arenburg May 04 '16 at 11:55
  • @DavidArenburg, I'm curious why this is generally a bad idea? I believe you, I just don't know. – Jason May 04 '16 at 12:06
  • @Jason For many reasons. Row names are messed up upon subsetting/reordering. They can't have duplicated values, they can be only of character class, it's harder to work with them in situation like joins or other data manipulation operations, etc. – David Arenburg May 04 '16 at 12:22
  • Still if you want to do that, then you can use rownames(df) <- df$a "a" as your 1st column . After that you can just remove the first column . – Pankaj Kaundal May 04 '16 at 12:23
  • @DavidArenburg, the thing is that i´m trying to plot with ggplot a dataset, and due to my experience with r i´m starting to think that for me is impossible...however i thought that a trasposition of the matrix could have helped me, but i was wrong.. and you were right – Jua' May 04 '16 at 14:17

0 Answers0