How to set the row names of a data frame passed on with the pipe %>% operator?

前端 未结 3 1045
借酒劲吻你
借酒劲吻你 2020-12-29 05:42

I have a data frame which I am dcasting using the reshape2 package, and I would like to remove the first column and have it become the row names of

3条回答
  •  囚心锁ツ
    2020-12-29 05:56

    with the later version of tibble, a more elegant solution exists:

    df <- df %>% pivot(.) %>% tibble::column_to_rownames('ID_full')
    

    Importantly, it works also when the column to turn to the rowname is passed as a variable, which is super-convenient, when inside the function!

提交回复
热议问题