简体   繁体   English

Tidyverse 和 dplyr- 错误 package 或命名空间

[英]Tidyverse and dplyr- error package or namespace

I can't seem to get the filter function to work along with the loading of tidyverse.我似乎无法让过滤器 function 与 tidyverse 的加载一起工作。 I have compared code and know that it is correct however I get error messages every time.我已经比较了代码并且知道它是正确的但是我每次都会收到错误消息。 I have checked multiple online resources and none seem to help.我检查了多个在线资源,但似乎没有任何帮助。 I also have updated all of my packages and restarted them.我还更新了所有软件包并重新启动它们。 Any help is appreciated!任何帮助表示赞赏!

This is my code:这是我的代码:

library(tidyverse)

ggplot(data = mpg) +
  geom_point(mapping = aes(x = displ, y = Hwy))

filter(mpg, cyl == 8)
filter(diamonds, carat > 3)

Errors:错误:

library(tidyverse)

Error: package or namespace load failed for ‘tidyverse’ in loadNamespace(I, 
c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
 namespace ‘rlang’ 0.4.2 is already loaded, but >= 0.4.3 is required
In addition: Warning message:
package ‘tidyverse’ was built under R version 3.6.3 

filter(mpg, cyl == 8)

Error in filter(mpg, cyl == 8) : object 'cyl' not found
    In addition: Warning messages:
    1: In data.matrix(data) : NAs introduced by coercion
    2: In data.matrix(data) : NAs introduced by coercion
    3: In data.matrix(data) : NAs introduced by coercion
    4: In data.matrix(data) : NAs introduced by coercion
    5: In data.matrix(data) : NAs introduced by coercion
    6: In data.matrix(data) : NAs introduced by coercion

    filter(diamonds, carat > 3)

    Error in filter(diamonds, carat > 3) : object 'carat' not found

Your issue is that tidyverse is not being loaded into your R session, and so when you call filter , it is from the stats package rather than dplyr. Your issue is that tidyverse is not being loaded into your R session, and so when you call filter , it is from the stats package rather than dplyr. This is why it's good practice to use namespaces in R, like dplyr::filter , so you know exactly which function you are calling.这就是为什么在 R 中使用命名空间是一种很好的做法,例如dplyr::filter ,这样您就可以确切地知道您正在调用哪个 function。

To fix the error loading tidyverse, update the rlang library:要修复加载 tidyverse 的错误,请更新rlang库:

update.packages()

And then try然后尝试

dplyr::filter(mtcars, cyl == 8)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:package 或“tidyverse”的命名空间加载失败:object “relocate”未由“namespace:dplyr”导出 - Error: package or namespace load failed for ‘tidyverse’: object ‘relocate’ is not exported by 'namespace:dplyr' R - dplyr- 减少数据 package 'storms' - R - dplyr- Reducing data package 'storms' R:dplyr-使用重新编码功能时出错 - R: dplyr- error in using recode function 错误:loadNamespace 中“tidyverse”的包或命名空间加载失败 - Error: package or namespace load failed for ‘tidyverse’ in loadNamespace 错误:package 或“tidyverse”的命名空间加载失败,没有 package 称为“reprex” - Error: package or namespace load failed for ‘tidyverse’ there is no package called ‘reprex’ 错误:package 或“tidyverse”的命名空间加载失败,没有名为“rlang”的 package - Error: package or namespace load failed for “tidyverse” there is no package called “rlang” 运行 R Markdown '包或命名空间加载失败'时出现 tidyverse 错误 - tidyverse error while running R Markdown 'package or namespace load failed' 库中的错误(tidyverse):没有名为'tidyverse'的包 - Error in library(tidyverse) : there is no package called ‘tidyverse’ 用 dplyr 编程 - 如何处理引号/enquotes - programming with dplyr- how to deal with quotes/enquotes dplyr-使用选择功能重命名列顺序 - dplyr- renaming sequence of columns with select function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM