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,380 points
22 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,020 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
25 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
59 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
85 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,020 points
244 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,020 points
20 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,020 points
66 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.