问题
I am trying to convert my regular data set to sparse format. All documentations have examples with 'sparse format' Can you help me please?
My sample data set:
ID Item
1 Avas
2 Alo
2 Erbi
8 Abra
8 Ali
9 Inj
10 Avas
11 Avas
回答1:
Convert to transaction class:
trans1 <- as(split(df1[,"Item"], df1[,"ID"]), "transactions")
Result:
summary(trans1)
# transactions as itemMatrix in sparse format with
# 6 rows (elements/itemsets/transactions) and
# 6 columns (items) and a density of 0.2222222
#
# most frequent items:
# Avas Abra Ali Alo Erbi (Other)
# 3 1 1 1 1 1
来源:https://stackoverflow.com/questions/28912938/converting-from-regular-format-to-sparse-format-for-arules-package