gpt4 book ai didi

r - 需要规则时使用的基本包。指定包不起作用

转载 作者:行者123 更新时间:2023-12-04 21:03:26 25 4
gpt4 key购买 nike

我正在尝试在 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)

当我在 session 开始时加载 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)

关于r - 需要规则时使用的基本包。指定包不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53185553/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com