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
• 10,450 points
109 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

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

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

answered 6 days ago in Data Analytics by anonymous
• 22,150 points
14 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,040 points
247 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
358 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,040 points
35 views
0 votes
1 answer
0 votes
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,040 points
459 views