r - How to rename backticked contained column names in dplyr -
i have following tibble:
library(tidyverse) df <- structure(list(`input paired-end (star)` = c(9394981, 100), `multi-mapped pair (star)` = c(1493691, 400), `uniquely mapped paired-end (star)` = c(6826405, 200), `unmapped pair (star-appx)` = c(1074885, 300)), class = c("tbl_df", "tbl", "data.frame"), row.names = 1:2, .names = c("input paired-end (star)", "multi-mapped pair (star)", "uniquely mapped paired-end (star)", "unmapped pair (star-appx)"))
that looks this:
# tibble: 2 × 4 `input paired-end (star)` `multi-mapped pair (star)` `uniquely mapped paired-end (star)` `unmapped pair (star-appx)` * <dbl> <dbl> <dbl> <dbl> 1 9394981 1493691 6826405 1074885 2 100 400 200 300
how can rename column too:
foo bar qux gop 9394981 6826405 1074885 1493691 100 200 300 400
an easy option setnames
can incorporated chain
library(dplyr) df %>% setnames(., c('foo', 'bar', 'qux', 'gop'))
Comments
Post a Comment