`dplyr`不兼容`r`中的`MASS`软件包 [英] `dplyr` not working with `MASS` package in `r`
问题描述
在 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屋!