1

I have the following dataset for which I want to generate association rules using FP growth

> head(order_pairs)
# A tibble: 6 x 2
  product_A          product_B                       
  <chr>              <chr>                           
1 Organic Egg Whites Michigan Organic Kale           
2 Organic Egg Whites Garlic Powder                   
3 Organic Egg Whites Coconut Butter                  
4 Organic Egg Whites Natural Sweetener               
5 Organic Egg Whites Carrots                         
6 Organic Egg Whites Original Unflavored Gelatine Mix

Following the example on the documentation here I performed the following steps before generating the rules.

train = sapply(orders_pairs,as.factor)
train = as.data.frame(train, check.names = FALSE)
transactions = as(train, 'transactions')
rules = rCBA::fpgrowth(transactions, support=0.01, confidence=0.01, maxLength=2, consequent="product_B", parallel=FALSE)
> head(train)
           product_A                        product_B
1 Organic Egg Whites            Michigan Organic Kale
2 Organic Egg Whites                    Garlic Powder
3 Organic Egg Whites                   Coconut Butter
4 Organic Egg Whites                Natural Sweetener
5 Organic Egg Whites                          Carrots
6 Organic Egg Whites Original Unflavored Gelatine Mix

A little reading led me to find that the error has something to do with the consequent parameter having a valid column name. However "product_B" is a valid column name in my data

> colnames(orders_pairs)
[1] "product_A" "product_B"

> colnames(train)
[1] "product_A" "product_B"

code-noob
  • 11
  • 1
  • 2
    It would be easier to help if you create a small reproducible example along with expected output. Read about [how to give a reproducible example](http://stackoverflow.com/questions/5963269). – Ronak Shah May 18 '21 at 10:48
  • @code-noob I ran into the same issue. Were you able to resolve it? – Mohamad Sahil Aug 31 '21 at 13:47

0 Answers0