Error casted by simple mutate using tidyverse or dplyr

别来无恙 提交于 2019-12-21 20:43:22

问题


I am having serious troubles using the tidyverse package that I cannot debug. As an example, "mutate" does not work properly even on past project I have already produced. This all started when I installed the following package:

library(pdftools)
library(tm)
library(stringi)
library(tidyverse)

(or library(dplyr) library(tidyr)) library(purrr))

And it still remains when I do a rm(list=ls()).

The only thing I haven't tried so forth is deinstalling R/RStudio and reinstalling it. I use RStudio version 1.0.153 and R version 3.4.1. I actually tried to reproduce the bug on other computers and this was obviously not working.

Here is an ad hoc example:

library(tidyverse)
emp.data <- data.frame(emp_id=c(1:5),emp_name=c("Rick","Dan","Michelle","Ryan","Gary"),
                       salary=c(623.3,515.2,611.0,729.0,843.25), 
                       start_date=as.Date(c("2012-01-01", "2013-09-23", "2014-11-15", "2014-05-11",
                         "2015-03-27"),
  stringsAsFactors = FALSE)
)
emp.data_new <- emp.data %>%
  mutate(RaisedSalary = salary*1.4)

emp.data is defined ok in my session. I would expect the addition of a new column in the new data frame emp.data.new ("RaisedSalary") and instead of this I get:

Error in mutate_impl(.data, dots) : Cannot convert object to a function: [type=NULL; target=CLOSXP, SPECIALSXP, or BUILTINSXP].

I also get this error message if I load tidyr/dplyr instead of tidyverse. I've lurked on the forum for more than 48 hours without finding anything close to this mistake. Has anyone already experienced such an error?

Outcome of sessionInfo():

R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252    LC_MONETARY=French_France.1252 LC_NUMERIC=C                   LC_TIME=French_France.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] wordcloud_2.6      RColorBrewer_1.1-2 SnowballC_0.6.0    bindrcpp_0.2       forcats_0.3.0      stringr_1.4.0      purrr_0.3.2        readr_1.1.1       
 [9] tibble_1.4.2       ggplot2_3.0.0      tidyverse_1.2.1    tidyr_0.8.0        dplyr_0.7.4        stringi_1.4.3      tm_0.7-6           NLP_0.2-0         
[17] pdftools_2.2       GCPM_1.2.2        

loaded via a namespace (and not attached):
 [1] qpdf_1.1           tidyselect_0.2.4   slam_0.1-45        reshape2_1.4.2     haven_1.1.1        lattice_0.20-35    colorspace_1.3-2   rlang_0.4.0       
 [9] pillar_1.2.2       foreign_0.8-69     glue_1.2.0         withr_2.1.2        modelr_0.1.1       readxl_1.1.0       bindr_0.1          plyr_1.8.4        
[17] munsell_0.5.0      gtable_0.2.0       cellranger_1.1.0   rvest_0.3.2        psych_1.8.3.3      parallel_3.4.1     broom_0.4.4        Rcpp_0.12.16      
[25] scales_1.0.0       jsonlite_1.5       RcppProgress_0.4.1 mnormt_1.5-5       askpass_1.1        hms_0.3            grid_3.4.1         cli_1.0.0         
[33] tools_3.4.1        magrittr_1.5       lazyeval_0.2.0     crayon_1.3.4       pkgconfig_2.0.1    xml2_1.1.1         lubridate_1.7.4    assertthat_0.2.0  
[41] httr_1.4.0         rstudioapi_0.7     R6_2.2.2           nlme_3.1-131       compiler_3.4.1

回答1:


Got this error with ver 3.5 in script that had previously worked - Updating rlang fixed issue




回答2:


I updated the dplyr by using install.packages("dplyr") and it worked. Except that now it gives me warning messages that rlang is not compatible with dplyr now. Still, it worked! Hope they will sort out the incompatibility soon. --- 2019/09/17



来源:https://stackoverflow.com/questions/56808725/error-casted-by-simple-mutate-using-tidyverse-or-dplyr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!