0

我正在尝试将我的常规数据集转换为稀疏格式。所有文档都有“稀疏格式”的例子你能帮帮我吗?

我的样本数据集:

ID  Item
1   Avas
2    Alo
2   Erbi
8   Abra
8    Ali
9    Inj
10  Avas
11  Avas
4

1 回答 1

0

转换为事务类:

trans1 <- as(split(df1[,"Item"], df1[,"ID"]), "transactions")

结果:

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 
于 2015-03-07T10:51:48.197 回答