需要规则时使用的基本包装。指定软件包不起作用

时间:2018-11-07 08:07:32

标签: r arules

我试图在arules包中编写一个格式文件,然后将其作为事务加载以进行关联规则挖掘。我无法使用此功能,因为R一直使用base::write函数而不是arules::write函数。

arules::write(x = dfSingle,
              file = "dfSingleFile",
              format = "single",
              quote = TRUE,
              sep = ",")

给出以下错误消息:

Error in base::write(x, file, ...) : 
unused arguments (format = "single", quote = TRUE)

当我在会话开始时加载arules软件包时,确实表示它屏蔽了base的write函数:

library(arules)
Loading required package: Matrix

Attaching package: ‘arules’
The following objects are masked from ‘package:base’: abbreviate, write

我已经尝试过重新安装arules软件包。我在Rstudio Server(1.1.414)中使用R 3.5.1。

对此有任何帮助吗?

1 个答案:

答案 0 :(得分:2)

检查dfSingle class ,如果不是"transactions",则将其传递给base::write,请参见示例:

library(arules)
data(Epub)

class(Epub)
# [1] "transactions"
# attr(,"package")
# [1] "arules"
arules::write(x = head(Epub),
              file = "test",
              format = "single",
              quote = TRUE,
              sep = ",")
# no errors!

class(mtcars)
#[1] "data.frame"
arules::write(x = mtcars,
              file = "test",
              format = "single",
              quote = TRUE,
              sep = ",")
# Error in base::write(x, file, ...) : 
#   unused arguments (format = "single", quote = TRUE)