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

0 votes

I'm trying to find frequent itemsets of a data set using arules package .i found this example but it doesn't work for me .

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 

i'm getting this error :"Error in df$item : object of type 'closure' is not subsettable"

Nov 15, 2018 in Data Analytics by Ali
• 11,360 points
1,751 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,840 points

Related Questions In Data Analytics

0 votes
1 answer

R Shiny Error: Object of type 'closure' is not subsettable

The error you mentioned happens when you ...READ MORE

answered Aug 20, 2019 in Data Analytics by anonymous
• 33,030 points
6,354 views
0 votes
1 answer
0 votes
1 answer

Error saying "duplicate 'row.names' are not allowed" when trying to setup my data for the mlogit-package

Take out the chid.var argument in your call to mlogit.data, ...READ MORE

answered Nov 12, 2018 in Data Analytics by Maverick
• 10,840 points
2,029 views
+1 vote
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,840 points
4,807 views
+1 vote
2 answers
0 votes
1 answer

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

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

answered Nov 15, 2018 in Data Analytics by Maverick
• 10,840 points
797 views
0 votes
1 answer
+1 vote
1 answer

"Error in eval(ei, envir) : object 'RDX2' not found" when trying to source the code in R

This is a very common issue that ...READ MORE

answered Oct 30, 2018 in Data Analytics by Maverick
• 10,840 points
5,101 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP