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"