6

I have following data frame:

              RMSE
A         0.03655830
B         0.24513014
C         0.02009853
D         0.02223135

I want to move column that has A,B,C,D to be the first column and add an index to the data.frame.

add-semi-colons
  • 16,582
  • 50
  • 135
  • 222

1 Answers1

20

try this:

df <- cbind(newColName = rownames(df), df)
rownames(df) <- 1:nrow(df)

hope this is what you meant, the result will be:

  newColName       RMSE
1          A 0.03655830
2          B 0.24513014
3          C 0.02009853
4          D 0.02223135
cccmir
  • 773
  • 4
  • 12