Both functions select() and rename() allows renaming by using assignment inside them. It would be nice to have the same feature in relocate()
#reprex
> library(tidyverse) > df <- tibble(a = 1, b = 1, c = 1, d = "a", e = "a", f = "a") > > rename(df, ffff = f) # A tibble: 1 x 6 a b c d e ffff <dbl> <dbl> <dbl> <chr> <chr> <chr> 1 1 1 1 a a a > select(df, ffff = f) # A tibble: 1 x 1 ffff <chr> 1 a > relocate(df, ffff = f) # A tibble: 1 x 6 f a b c d e <chr> <dbl> <dbl> <dbl> <chr> <chr> 1 a 1 1 1 a a
It would be nice to have instead
> relocate(df, ffff = f) # A tibble: 1 x 6 ffff a b c d e <chr> <dbl> <dbl> <dbl> <chr> <chr> 1 a 1 1 1 a a
#sessionInfo
sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.2
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] ru_RU.UTF-8/ru_RU.UTF-8/ru_RU.UTF-8/C/ru_RU.UTF-8/ru_RU.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] forcats_0.5.0 stringr_1.4.0 dplyr_1.0.2 purrr_0.3.4 readr_1.4.0 tidyr_1.1.2
[7] tibble_3.0.4 ggplot2_3.3.2 tidyverse_1.3.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 cellranger_1.1.0 pillar_1.4.6 compiler_4.0.2 dbplyr_1.4.4
[6] tools_4.0.2 jsonlite_1.7.1 lubridate_1.7.9 lifecycle_0.2.0 gtable_0.3.0
[11] pkgconfig_2.0.3 rlang_0.4.8 reprex_0.3.0 cli_2.0.2 DBI_1.1.0
[16] rstudioapi_0.11 yaml_2.2.1 haven_2.3.1 withr_2.3.0 xml2_1.3.2
[21] httr_1.4.2 fs_1.5.0 generics_0.0.2 vctrs_0.3.4 hms_0.5.3
[26] grid_4.0.2 tidyselect_1.1.0 glue_1.4.2 R6_2.4.1 fansi_0.4.1
[31] readxl_1.3.1 modelr_0.1.8 blob_1.2.1 magrittr_1.5 backports_1.1.10
[36] scales_1.1.1 ellipsis_0.3.1 rvest_0.3.6 assertthat_0.2.1 colorspace_1.4-1
[41] stringi_1.5.3 munsell_0.5.0 broom_0.7.2 crayon_1.3.4