我有以下格式的数据:
TxnId Items
1 a
1 b
1 c
2 r
2 t
其中“TxnId”和“Items”是列。我在 R 中导入了文件并运行了以下命令:
df_fact <- data.frame(lapply(MyData,as.factor))
df_trans <- as(df_fact, 'transactions')
当我运行 apriori 命令时,它会引发错误。
rules = apriori(df_trans, parameter=list(supp=0.95, conf=0.95, target=”rules”))
inspect(rules)
#NULL
inspect(rules[1:5])
Error in inspect(rules[1:5]) :
error in evaluating the argument 'x' in selecting a method for function 'inspect': Error in slot(x, s)[i] : subscript out of bounds
也让我知道 R 接受数据的格式。