I want to do the opposite of: Convert row names into first column
Somewhere down the chain of pipes I would like to add row names to the data frame, for example, I w
You can use row.names<-:
row.names<-
mtcars <- mtcars %>% `row.names<-`(as.character(1:nrow(mtcars)))
Should work. As a demo:
df <- data.frame(x = 1:5, y = 2:6) df <- df %>% `row.names<-`(letters[1:5]) df # x y # a 1 2 # b 2 3 # c 3 4 # d 4 5 # e 5 6