0

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
Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
Murali
  • 579
  • 1
  • 6
  • 20

1 Answers1

0

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 
bergant
  • 7,122
  • 1
  • 20
  • 24