次の形式のデータがあります。
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 がデータを受け入れる形式を教えてください。