微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

R 错误:“找不到函数“变异””跟随管道操作员

如何解决R 错误:“找不到函数“变异””跟随管道操作员

我正在尝试在我的 R 代码中使用管道运算符,但我不断收到错误消息,指出找不到“mutate”函数。我已经安装/加载了显然包含 magrittr 的 dplyr 和 tidyverse,所以我不知道该怎么做。

非常感谢任何帮助,谢谢。

df_reg <- df %>% 
  group_by(hhid) %>% 
  mutate(
    across(
      .col = c(all_of(cons_list),all_of(percap_cons_list)),.fns = function(x) x / 1000,.names = "{col}"
    ),Error in mutate(.,across(.col = c(all_of(cons_list),: 
  Could not find function "mutate"

SessionInfo() 输出

> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

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

other attached packages:
[1] stargazer_5.2.2 lfe_2.8-6       Matrix_1.2-17   haven_2.4.1     sf_0.9-8       

loaded via a namespace (and not attached):
 [1] zoo_1.8-8          tidyselect_1.1.0   xfun_0.16          purrr_0.3.4       
 [5] lattice_0.20-38    colorspace_1.4-1   vctrs_0.3.6        generics_0.0.2    
 [9] yaml_2.2.1         rlang_0.4.10       e1071_1.7-6        pillar_1.4.6      
[13] glue_1.4.2         DBI_1.0.0          dbplyr_2.1.1       modelr_0.1.8      
[17] lifecycle_1.0.0    munsell_0.5.0      gtable_0.3.0       knitr_1.29        
[21] forcats_0.5.1      class_7.3-15       broom_0.7.6        Rcpp_1.0.5        
[25] KernSmooth_2.23-15 xtable_1.8-4       readr_1.4.0        scales_1.1.1      
[29] backports_1.1.4    classInt_0.4-3     jsonlite_1.7.2     ggplot2_3.3.4     
[33] hms_1.0.0          dplyr_1.0.4        grid_3.6.1         cli_2.5.0         
[37] tools_3.6.1        sandwich_3.0-0     magrittr_2.0.1     proxy_0.4-25      
[41] tibble_3.0.4       Formula_1.2-4      pacman_0.5.1       Crayon_1.4.1      
[45] tidyr_1.1.2        pkgconfig_2.0.2    ellipsis_0.3.1     lubridate_1.7.10  
[49] assertthat_0.2.1   httr_1.4.2         rstudioapi_0.13    R6_2.4.0          
[53] units_0.7-1        compiler_3.6.1  

库(dplyr)输出

> library(dplyr)
Warning: package ‘dplyr’ was built under R version 3.6.3

Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

    filter,lag

The following objects are masked from ‘package:base’:

    intersect,setdiff,setequal,union

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。