`dplyr`不兼容`r`中的`MASS`软件包 [英] `dplyr` not working with `MASS` package in `r`

查看:120
本文介绍了`dplyr`不兼容`r`中的`MASS`软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

R中一起使用软件包 MASS dplyr 时遇到一个奇怪的问题使用 RStudio 。以下代码

I am encountering a strange problem in using packages MASS and dplyr together in R using RStudio. The following code

library(dplyr)
select(iris, starts_with("Petal"))

可以正常工作,并给我正确的输出。但是,如果我尝试加载 MASS 软件包并使用相同的代码

works and gives me the right output. But if I try to load MASS package and use the same code

library(MASS)
library(dplyr)
select(iris, starts_with("Petal"))

我遇到错误

select(iris, starts_with("Petal"))
Error in select(iris, starts_with("Petal")) : 
  unused argument (starts_with("Petal"))

RStudio中将 dplyr MASS 一起使用是否存在已知问题。我在 MASS 之后加载 dplyr ,以免掩盖 select 来自 dplyr 。我还卸载并重新安装了 RStudio ,但错误仍然存​​在。

Is there a known issue with using dplyr with MASS in RStudio. I am loading dplyr after MASS so as not to mask the select from dplyr. I have un-installed and re-installed my RStudio also, but the error persists.

我正在使用R版本 3.2.2 MASS 版本- 7.3-45 dplyr 版本 0.5.0

I am using R Version 3.2.2, MASS version - 7.3-45 and dplyr version 0.5.0

任何帮助都会

sn248

推荐答案

两个软件包都有一个 select 函数。

Both packages have a select function.

使用 dplyr :: select()或根据需要使用 MASS :: select()来防止错误。

Use dplyr::select() or MASS::select() as needed to prevent errors.

另一个流行的冲突是 dplyr :: filter signal :: filter

Another popular conflict is the dplyr::filter vs signal::filter.

如果您不这样做每次输入一次 dselect都不希望输入程序包名称-dplyr :: select ,然后使用 dselect 始终都是这样。

If you don't want to type the package name every time you can type once dselect <- dplyr::select and then use dselect all the time instead.

这篇关于`dplyr`不兼容`r`中的`MASS`软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆