Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with rename: [renamed variable] must be a symbol or a string, not formula #3232

Closed
jrosen48 opened this issue Nov 30, 2017 · 6 comments

Comments

@jrosen48
Copy link

jrosen48 commented Nov 30, 2017

When I run rename(), like I have 100s of times before, I get a strange error:

library(dplyr, warn.conflicts = F)
rename(iris, sl = Sepal.Length)
#> Error: `sl` = Sepal.Length must be a symbol or a string, not formula

What am I missing here?

Here is my session info.:


> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.1

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.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] dplyr_0.7.4

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.14     knitr_1.17       bindr_0.1        whisker_0.3-2   
 [5] magrittr_1.5     devtools_1.13.4  R6_2.2.2         rlang_0.1.4.9000
 [9] stringr_1.2.0    tools_3.4.2      clipr_0.4.0      withr_2.1.0.9000
[13] htmltools_0.3.6  yaml_2.1.14      rprojroot_1.2    digest_0.6.12   
[17] assertthat_0.2.0 tibble_1.3.4     bindrcpp_0.2     callr_1.0.0     
[21] memoise_1.1.0    glue_1.2.0       evaluate_0.10.1  rmarkdown_1.8   
[25] reprex_0.1.1     stringi_1.1.6    compiler_3.4.2   backports_1.1.1 
[29] pkgconfig_2.0.1 
@batpigandme
Copy link
Contributor

batpigandme commented Nov 30, 2017

I just ran the same and it was fine. From your sessionInfo, it looks like you haven't actually loaded dplyr…

library(dplyr, warn.conflicts = F)
rename(iris, sl = Sepal.Length)
#>      sl Sepal.Width Petal.Length Petal.Width    Species
#> 1   5.1         3.5          1.4         0.2     setosa
#> 2   4.9         3.0          1.4         0.2     setosa
#> 3   4.7         3.2          1.3         0.2     setosa
#> 4   4.6         3.1          1.5         0.2     setosa
#> 5   5.0         3.6          1.4         0.2     setosa
#> 6   5.4         3.9          1.7         0.4     setosa
#> 7   4.6         3.4          1.4         0.3     setosa
#> 8   5.0         3.4          1.5         0.2     setosa
#> 9   4.4         2.9          1.4         0.2     setosa
#> 10  4.9         3.1          1.5         0.1     setosa
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] dplyr_0.7.4.9000
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_0.12.14          digest_0.6.12         rprojroot_1.2        
#>  [4] assertthat_0.2.0.9000 R6_2.2.2              backports_1.1.1      
#>  [7] magrittr_1.5          evaluate_0.10.1       rlang_0.1.4          
#> [10] stringi_1.1.6         bindrcpp_0.2          rmarkdown_1.8        
#> [13] tools_3.4.2           stringr_1.2.0         glue_1.2.0           
#> [16] purrr_0.2.4           yaml_2.1.14           compiler_3.4.2       
#> [19] pkgconfig_2.0.1       htmltools_0.3.6       tidyselect_0.2.3     
#> [22] bindr_0.1             knitr_1.17.20         tibble_1.3.4

Created on 2017-11-29 by the reprex
package
(v0.1.1.9000).

@jrosen48
Copy link
Author

jrosen48 commented Nov 30, 2017

sorry, just updated the session info above (I had copied the code to the clipboard to run the reprex, but hadn't run it). I'm pretty sure this didn't work, but when I install the development version, it seems to just fine:

library(dplyr, warn.conflicts = F)
rename(iris, sl = Sepal.Length) %>% str()
#> 'data.frame':    150 obs. of  5 variables:
#>  $ sl          : num  5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
#>  $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
#>  $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
#>  $ Petal.Width : num  0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
#>  $ Species     : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...

Here's my session info (below) - the same (I think) except for the dplyr after installing the development version is dplyr_0.7.4.9000 instead of dplyr_0.7.4. Can't seem to find any recent issues or commits referencing this. Thank you for your help!

> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.1

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.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] dplyr_0.7.4.9000

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.14     knitr_1.17       bindr_0.1        whisker_0.3-2   
 [5] magrittr_1.5     devtools_1.13.4  tidyselect_0.2.3 R6_2.2.2        
 [9] rlang_0.1.4.9000 httr_1.3.1       stringr_1.2.0    tools_3.4.2     
[13] git2r_0.19.0     clipr_0.4.0      withr_2.1.0.9000 htmltools_0.3.6 
[17] yaml_2.1.14      rprojroot_1.2    digest_0.6.12    assertthat_0.2.0
[21] tibble_1.3.4     bindrcpp_0.2     purrr_0.2.4      callr_1.0.0     
[25] curl_3.0         memoise_1.1.0    glue_1.2.0       evaluate_0.10.1 
[29] rmarkdown_1.8    reprex_0.1.1     stringi_1.1.6    compiler_3.4.2  
[33] backports_1.1.1  pkgconfig_2.0.1

@jrosen48
Copy link
Author

@batpigandme could I ask if you could tell me what version of dplyr you have installed?

@batpigandme
Copy link
Contributor

@jrosen84 I ran that one with the dev version (should be in the sessionInfo of the reprex-- sorry, I'm on my phone atm). But rename was working fine (as far as I can recall) in the CRAN version, too. I'll double check, though.

@batpigandme
Copy link
Contributor

@jrosen48 just re-ran things with the current CRAN version of dplyr (0.7.4) and everything checks out!

library(dplyr, warn.conflicts = F)
df <- rename(iris, sl = Sepal.Length)
head(df)
#>  sl Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1         3.5          1.4         0.2  setosa
#> 2 4.9         3.0          1.4         0.2  setosa
#> 3 4.7         3.2          1.3         0.2  setosa
#> 4 4.6         3.1          1.5         0.2  setosa
#> 5 5.0         3.6          1.4         0.2  setosa
#> 6 5.4         3.9          1.7         0.4  setosa

It was fine, too, when I didn't assign to df, just did that for ease of reading.

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: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.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] dplyr_0.7.4

loaded via a namespace (and not attached):
 [1] compiler_3.4.2   magrittr_1.5     assertthat_0.2.0 R6_2.2.2         tools_3.4.2      bindrcpp_0.2    
 [7] glue_1.2.0       tibble_1.3.4     Rcpp_0.12.14     packrat_0.4.8-1  pkgconfig_2.0.1  rlang_0.1.4     
[13] bindr_0.1

@jrosen48
Copy link
Author

jrosen48 commented Dec 3, 2017

thanks @batpigandme!

lionel- added a commit to r-lib/rlang that referenced this issue Jan 14, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jun 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants