Here is a reprex:
library(tidyverse)
#> โโ Attaching packages โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ tidyverse 1.2.1 โโ
#> โ ggplot2 2.2.1.9000 โ purrr 0.2.4
#> โ tibble 1.3.4 โ dplyr 0.7.4
#> โ tidyr 0.7.2 โ stringr 1.2.0
#> โ readr 1.1.1 โ forcats 0.2.0
#> โโ Conflicts โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ tidyverse_conflicts() โโ
#> โ dplyr::filter() masks stats::filter()
#> โ dplyr::lag() masks stats::lag()
df = data.frame(old_var = 1:3) %>%
rename(new_var = old_var)
#> Error: `new_var` = old must be a symbol or a string, not formula
NB This issue was closed earlier but not resolved (the problem was not due to the problem @batpigandme identified).
Adding session info here in case it helps:
sessionInfo()
#> R version 3.4.2 (2017-09-28)
#> Platform: x86_64-apple-darwin16.7.0 (64-bit)
#> Running under: macOS Sierra 10.12.6
#>
#> Matrix products: default
#> BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
#> LAPACK: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
#>
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> other attached packages:
#> [1] reprex_0.1.1 shiny_1.0.5 forcats_0.2.0 stringr_1.2.0 dplyr_0.7.4 purrr_0.2.4 readr_1.1.1
#> [8] tidyr_0.7.2 tibble_1.3.4 ggplot2_2.2.1.9000 tidyverse_1.2.1
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> loaded via a namespace (and not attached):
#> [1] Rcpp_0.12.14 lubridate_1.7.1 lattice_0.20-35 assertthat_0.2.0 rprojroot_1.2 digest_0.6.12
#> [7] psych_1.7.8 mime_0.5 R6_2.2.2 cellranger_1.1.0 plyr_1.8.4 backports_1.1.1
#> [13] evaluate_0.10.1 httr_1.3.1 rlang_0.1.4.9000 lazyeval_0.2.1 readxl_1.0.0 rstudioapi_0.7.0-9000
#> [19] miniUI_0.1.1 whisker_0.3-2 callr_1.0.0.9000 rmarkdown_1.8 devtools_1.13.4 shinyjs_0.9.1
#> [25] foreign_0.8-69 munsell_0.4.3 broom_0.4.3 compiler_3.4.2 httpuv_1.3.5 modelr_0.1.1
#> [31] pkgconfig_2.0.1 mnormt_1.5-5 clipr_0.4.0 htmltools_0.3.6 crayon_1.3.4 withr_2.1.0
#> [37] grid_3.4.2 nlme_3.1-131 jsonlite_1.5 xtable_1.8-2 gtable_0.2.0 magrittr_1.5
#> [43] scales_0.5.0.9000 cli_1.0.0 stringi_1.1.6 debugme_1.1.0 reshape2_1.4.2 bindrcpp_0.2
#> [49] xml2_1.1.1 tools_3.4.2 glue_1.2.0 hms_0.4.0 processx_2.0.0.1 parallel_3.4.2
#> [55] yaml_2.1.15 colorspace_1.3-2 rvest_0.3.2 memoise_1.1.0 knitr_1.17 bindr_0.1
#> [61] haven_1.1.0
Hi,
As @batpigandme showed in her previous response, it works fine with last dplyr version. I run you reprex with no error.
library(tidyverse)
packageVersion("dplyr")
#> [1] '0.7.4'
df <- data.frame(old_var = 1:3) %>%
rename(new_var = old_var)
df
#> new_var
#> 1 1
#> 2 2
#> 3 3
Created on 2017-12-03 by the reprex package (v0.1.1.9000).
Thanks for the quick responses @batpigandme and @cderv. No clue where the error is coming from then :(
I've just updated packages via the Update Packages routine in RStudio, and now get the error for the MWE posted above.
Any hints for possible culprits would be greatly appreciated!
Removing all the tidyverse packages and re-installing did not solve the problem.
Can you try installing the dev version of dplyr:
# install.packages("devtools")
devtools::install_github("tidyverse/dplyr")
note: continuation of #3239
library(tidyverse)
df = data.frame(old = 1:3) %>%
rename(new_var = old)
df
#> new_var
#> 1 1
#> 2 2
#> 3 3
sessionInfo()
#> R version 3.4.2 (2017-09-28)
#> Platform: x86_64-apple-darwin15.6.0 (64-bit)
#> Running under: macOS Sierra 10.12.6
#>
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
#>
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] forcats_0.2.0 stringr_1.2.0 dplyr_0.7.4.9000
#> [4] purrr_0.2.4 readr_1.1.1.9000 tidyr_0.7.2
#> [7] tibble_1.3.4 ggplot2_2.2.1.9000 tidyverse_1.2.1
#>
#> loaded via a namespace (and not attached):
#> [1] Rcpp_0.12.14 cellranger_1.1.0 compiler_3.4.2
#> [4] plyr_1.8.4 bindr_0.1 tools_3.4.2
#> [7] digest_0.6.12 lubridate_1.7.1 jsonlite_1.5
#> [10] evaluate_0.10.1 nlme_3.1-131 gtable_0.2.0
#> [13] lattice_0.20-35 pkgconfig_2.0.1 rlang_0.1.4
#> [16] psych_1.7.8 cli_1.0.0 yaml_2.1.14
#> [19] parallel_3.4.2 haven_1.1.0 bindrcpp_0.2
#> [22] xml2_1.1.9000 httr_1.3.1 knitr_1.17.20
#> [25] hms_0.4.0 rprojroot_1.2 grid_3.4.2
#> [28] tidyselect_0.2.3 glue_1.2.0 R6_2.2.2
#> [31] readxl_1.0.0 foreign_0.8-69 rmarkdown_1.8
#> [34] modelr_0.1.1 reshape2_1.4.2.9000 magrittr_1.5
#> [37] backports_1.1.1 scales_0.5.0.9000 htmltools_0.3.6
#> [40] rvest_0.3.2.9000 assertthat_0.2.0.9000 mnormt_1.5-5
#> [43] colorspace_1.3-2 stringi_1.1.6 lazyeval_0.2.1.9000
#> [46] munsell_0.4.3 broom_0.4.3 crayon_1.3.4
Created on 2017-12-03 by the reprex package (v0.1.1.9000).
The problem does __not__ arise with the dev version of dplyr.
Most helpful comment
The problem does __not__ arise with the dev version of dplyr.