R inspect()函数出现错误

R inspect()函数出现错误,r,matrix,text-mining,arules,R,Matrix,Text Mining,Arules,我的目标是将关联规则应用于文本挖掘 我有以下字符串示例: sample.word = c("abstracting","abstracting workflow","access control","access information","access methods","access patterns","access permissions","access to government information","accountability","acetamides") 然后我做一个所

我的目标是将关联规则应用于文本挖掘

我有以下字符串示例:

sample.word = c("abstracting","abstracting workflow","access control","access information","access methods","access patterns","access permissions","access to government information","accountability","acetamides")
然后我做一个所有值都为0的矩阵

incidence.matrix_sample <- matrix(0, nrow=5, ncol=length(sample.word))
同样的问题,使用apriori函数来关联矩阵_样本

Errore in UseMethod("inspect", x) : 
  no applicable method for 'inspect' applied to an object of class "c('rules', 'associations')"

这几天我都在努力想问题出在哪里。。有人能帮我吗?

这个错误的原因是arules和tm library都有inspect()方法,因此加载顺序会影响该方法的实现方式

解决此问题的方法是先分离一个库,然后再对由其他库生成的对象使用inspect()方法。例如,在获得关联矩阵后,我需要分离tm包:

detach(package:tm, unload=TRUE)
然后加载arules库并对arules对象使用inspect()方法


我希望它有用

您可以使用
arules::inspect(关联矩阵\u示例)


::
指定要使用哪个库

先读后发。
检查
是由
arules
包提供的S4方法,但您的错误消息表明您有一个同名的S3方法,可能来自另一个包。如果不加载另一个包,或者显式指定名称空间(
arules::inspect
),问题应该会消失。感谢您的回复,但我尝试使用arules::inspect,但似乎不起作用问题是。。。tm和arules包装有检验方法。。因此,在使用arules之前,我需要分离tm软件包:detach(package:tm,unload=TRUE),然后加载arules谢谢您的帮助我以为是这样的,但我忘了加载了tm库:)
incidence.matrix_sample <- as(incidence.matrix_sample, "itemMatrix")
incidence.matrix_sample <- as(incidence.matrix_sample, "transactions")
inspect(incidence.matrix_sample)
Errore in UseMethod("inspect", x) : 
  no applicable method for 'inspect' applied to an object of class "c('matrix', 'double', 'numeric')"
Errore in UseMethod("inspect", x) : 
  no applicable method for 'inspect' applied to an object of class "c('rules', 'associations')"
detach(package:tm, unload=TRUE)