How to add a row names to a data frame in a magrittr chain

前端 未结 4 1122
傲寒
傲寒 2021-01-13 10:49

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

4条回答
  •  孤独总比滥情好
    2021-01-13 11:03

    Other possibility is to use set_rownames alias from magrittr library.

    mtcars <- 
      mtcars %>%
      set_rownames(as.character(1:nrow(mtcars)))
    

提交回复
热议问题