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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With