R Programming: Market Basket Analysis Error

0 votes

I'm trying to perform Market Basket Analysis and after executing the inspect command I get the following error:

Error in slot(x, s)[i] : subscript out of bounds.

This is my code:

basket_rules <- apriori(txn, parameter = list(sup = 0.005, conf = 0.01, target="rules"))
basket.sorted <- sort(basket_rules, by = "lift")
itemFrequencyPlot(txn, topN = 25)
inspect(basket.sorted[1:5])
Feb 11 in Data Analytics by Tyrion anex
• 8,280 points
72 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

The basket.sorted() has less than 5 rules. Refer the below example:

library(arules)
data("Adult")
basket_rules <- apriori(Adult, parameter = list(sup = 0.9, conf = 0.5, target="rules"))
basket.sorted <- sort(basket_rules, by = "lift")
inspect(basket.sorted[1:5])
# Error in slot(x, s)[i] : subscript out of bounds
basket.sorted
# set of 2 rules
inspect(basket.sorted[1:2])
#     lhs    rhs                 support   confidence lift
# [1] {}  => {capital-gain=None} 0.9173867 0.9173867  1   
# [2] {}  => {capital-loss=None} 0.9532779 0.9532779  1   
answered Feb 11 by Sophie may
• 9,250 points

Related Questions In Data Analytics

0 votes
1 answer

Error: could not find function - R Programming

This error usually occurs when a package ...READ MORE

answered Oct 29, 2018 in Data Analytics by Maverick
• 10,020 points
161 views
0 votes
1 answer

"no applicable method" Error in r programming

This is caused by using an object-oriented ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 36,220 points
36 views
0 votes
1 answer

“subscript out of bounds” Error in r programming

This error is likely to occur when ...READ MORE

answered Oct 31, 2018 in Data Analytics by Kalgi
• 36,220 points
741 views
0 votes
1 answer

R Programming error: twitteR OAuthFactory object

You need to install the following packages: install.packages(c('ROA ...READ MORE

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

R programming error

Alright, you can either use gsub to match the ...READ MORE

answered Dec 18, 2018 in Data Analytics by Tyrion anex
• 8,280 points
10 views
0 votes
1 answer

R Programming: regexpr error

The below code will help: gregexpr("D", x) # [[1]] # ...READ MORE

answered Feb 21 in Data Analytics by Tyrion anex
• 8,280 points
17 views
0 votes
1 answer

R programming: Graphs

Try this: ggplot(dfc, aes(x=x, y=y, colour=f, fill=f, ymin=y-se, ...READ MORE

answered Feb 21 in Data Analytics by Tyrion anex
• 8,280 points
16 views
0 votes
1 answer

R programming: Classifying wine dataset

Run the below code, it should work: wineData$taste ...READ MORE

answered Feb 27 in Data Analytics by Sophie may
• 9,250 points
30 views
0 votes
1 answer

R programming: Unexpected symbol error

Format your code this way: myfunction <- function() ...READ MORE

answered Dec 17, 2018 in Data Analytics by Sophie may
• 9,250 points
132 views
0 votes
1 answer

R Programming error in 'fert'

You're using a factor: fert <- factor(c(50,20,10,10,20,50)) levels(fert) #[1] ...READ MORE

answered Dec 27, 2018 in Data Analytics by Sophie may
• 9,250 points
36 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.