I am using SparkR and trying to convert a "SparkDataFrame" to "transactions" in order to mine association of items/ products.
I have found a similar example on this link https://blog.aptitive.com/building-the-transactions-class-for-association-rule-mining-in-r-using-arules-and-apriori-c6be64268bc4 but this is only if you are working with an R data.frame. I currently have my data in this format;
CUSTOMER_KEY_h PRODUCT_CODE
1 SAVE
1 CHEQ
1 LOAN
1 LOAN
1 CARD
1 SAVE
2 CHEQ
2 LOAN
2 CTSAV
2 SAVE
2 CHEQ
2 SAVE
2 CARD
2 CARD
3 LOAN
3 CTSAV
4 SAVE
5 CHEQ
5 SAVE
5 CARD
5 LOAN
5 CARD
6 CHEQ
6 CHEQ
and would like to end up with something like this;
CUSTOMER_KEY_h PRODUCT_CODE
1 {SAVE, CHEQ, LOAN, LOAN , CARD, SAVE}
2 {CHEQ, LOAN, CTSAV, SAVE, CHEQ, SAVE, CARD, CARD}
3 {LOAN, CTSAV}
4 {SAVE}
5 {CHEQ, SAVE, CARD, LOAN, CARD}
6 {CHEQ, CHEQ}
Alternatively, If I can get the equivalent of this R script in SparkR
df2 <- apply(df,2,as.logical) that would be helpful.