Converting from regular format to sparse format for arules package

有些话、适合烂在心里 提交于 2019-12-10 12:14:38

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!