I have a data frame which I am dcast
ing using the reshape2
package, and I would like to remove the first column and have it become the row names of
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!
will this do?
iris %>% `rownames<-`(seq_len(nrow(iris)))
You can use the magrittr
alias set_rownames
:
df %>% set_rownames(.$ID_full)