Question
The following table shows sales of different items (A, B, C,....,G) at a grocery. Write R-codes possibly usingfor loops to calculate the Jaccard distance in
The following table shows sales of different items (A, B, C,....,G) at a grocery. Write R-codes possibly using"for" loops to calculate the Jaccard distance in order to compute similarities between all shopping basket pairs. Ex:The Jaccard distance for shopping baskets CA and CB is defined by
Shopping baskets | A | B | C | D | E | F | G |
CA | 5 | 0 | 0 | 0 | 2 | 1 | 2 |
CB | 2 | 1 | 2 | 0 | 0 | 0 | 0 |
CC | 0 | 0 | 1 | 4 | 0 | 0 | 1 |
CD | 0 | 0 | 2 | 0 | 1 | 1 | 2 |
CE | 6 | 2 | 2 | 0 | 1 | 1 | 2 |
CF | 4 | 0 | 0 | 2 | 0 | 0 | 2 |
I have got the following nice R-codes from sombody for the problem but mistakenly programmed for jaccard distance between shopping items instead of shopping baskets. Please fix that problem in the program below.
# reading the data from csv groccery
#getting all column nameexcpet first one b
#creating a list to store jacard distance for all pair l
for(x in b){ for(y in b){ if(x!=y){ num
#printing jacard distacne for each paire for(x in names(l)){ print(paste(x,l[[x]],sep = " "),quote=FALSE) cat(" ") }
CA n CB CA U CBStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started