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。
对此有什么帮助吗?
解决方案
检查 的类,dfSingle
如果不是,"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)
推荐阅读
- css - 路由器插座的粘性底部元件
- java - Spring Security 中的自定义表达式
- excel - Excel VBA 临时保存值
- python - geopandas legend_kwds 似乎被忽略了
- html - 为什么对象适合不影响图像?
- html - 无法将徽标居中
- angular - 页面重新加载后 APP_INITIALIZER 未定义的结果
- python - Pygame我的敌人类在移动后消失了
- java - 自定义排序算法性能(对比 Arrays.sort() 和 parallelSort())
- javascript - 使用 PUSH 和 SHIFT 从 json 数组中提取的数据未完全初始化数组