Trying to find frequent itemsets of a data set using arules package

0 votes

Trying to find frequent itemsets of a data set using arules package

ID <- c("A123","A123","A123","A123","B456","B456","B456")
item <- c("bread", "butter", "milk", "eggs", "meat","milk", "peas")

df <- data.frame(ID = ID, item = item)

library(arules)

trans <- as(split(df$item, df$ID), "transactions")

the result that i want is :

#   items                    transactionID
# 1 {bread,butter,eggs,milk} A123         
# 2 {meat,milk,peas}         B456 
Nov 15, 2018 in Data Analytics by Ali
• 10,450 points
28 views

1 answer to this question.

0 votes

Try replacing

ID <- c("A123","A123","A123","A123","B456","B456","B456")
item <- c("bread", "butter", "milk", "eggs", "meat","milk", "peas")
df <- data.frame(ID = ID, item = item)

with

ID=c("A123","A123","A123","A123","B456","B456","B456")
item=c("bread", "butter", "milk", "eggs", "meat","milk", "peas")
trans <- as(split(df$item, df$ID), "transactions")
answered Nov 15, 2018 by Maverick
• 10,040 points

Related Questions In Data Analytics

0 votes
1 answer
0 votes
1 answer

How to join a list of data frames using map()

You can use reduce set.seed(24) r1 <- map(c(5, 10, ...READ MORE

answered Apr 11, 2018 in Data Analytics by kappa3010
• 2,010 points
29 views
0 votes
1 answer

How to change the value of a variable using R programming in a data frame?

Try this: df$symbol <- as.character(df$symbol) df$symbol[df$symb ...READ MORE

answered Jan 11 in Data Analytics by Tyrion anex
• 8,280 points
74 views
0 votes
1 answer

Building Random Forest on a data-set comprising of missing(NA) values

You have two options, either impute the ...READ MORE

answered Apr 2, 2018 in Data Analytics by Bharani
• 4,550 points
95 views
0 votes
1 answer

Error saying "vector size cannot be NA" when using R with data mining

You can use the removesparseterm function.  Removes sparse ...READ MORE

answered Nov 15, 2018 in Data Analytics by Maverick
• 10,040 points
283 views
+1 vote
2 answers
0 votes
1 answer

Clean a set of data using R

Try this: NCM <- c(5,1,3,2,4) Mbrand <- c(1,5,3,4,2) fac<-factor(Mbrand, levels ...READ MORE

answered Nov 13, 2018 in Data Analytics by Maverick
• 10,040 points
23 views
0 votes
1 answer

Error saying "Error in df$item : object of type 'closure' is not subsettable" when trying to use arules package

Try replacing ID <- c("A123","A123","A123","A123","B456","B456","B456") item <- c("bread", "butter", ...READ MORE

answered Nov 15, 2018 in Data Analytics by Maverick
• 10,040 points
81 views