无法将数据框转换为交易对象 [英] Cannot convert dataframe to transactions object

查看:120
本文介绍了无法将数据框转换为交易对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用arules包来练习使用R的挖掘关联规则. 数据是

I want to use the arules package to practice mining association rules with R. The data is

datt <- structure(list(Item1 = c(0L, 0L, 0L, 1L, 0L, 0L, 0L, 1L, 0L, 
0L), Item2 = c(0L, 0L, 0L, 1L, 0L, 1L, 1L, 0L, 0L, 0L), Item3 = c(0L, 
1L, 0L, 1L, 0L, 1L, 1L, 1L, 0L, 0L), Item4 = c(0L, 0L, 0L, 1L, 
0L, 0L, 0L, 0L, 0L, 0L), Item5 = c(1L, 0L, 0L, 1L, 0L, 0L, 0L, 
0L, 0L, 1L), Item6 = c(0L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L
), Item7 = c(0L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 0L), Item8 = c(0L, 
1L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L), Item9 = c(0L, 1L, 1L, 1L, 
0L, 0L, 0L, 0L, 1L, 0L), Item10 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L)), .Names = c("Item1", "Item2", "Item3", "Item4", 
"Item5", "Item6", "Item7", "Item8", "Item9", "Item10"), row.names = c(2L, 
3L, 4L, 5L, 6L, 8L, 9L, 10L, 11L, 12L), class = c("cast_df", 
"data.frame"))

这样做

table5 <- as(datt, "transactions")

出现此错误:

Error in as(datt, "transactions") : 
  no method or default for coercing "cast_df" to "transactions"

我该怎么做才能将对象转换为交易"对象?

What can I do to convert my object into a 'transactions' object?

推荐答案

也许您忘记加载arules程序包.

Maybe you forget to load arules package.

library(arules)

这篇关于无法将数据框转换为交易对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆