Stack Exchange
Coercing "factor" to "transactions" R when using Apriori
I want to perform the Apriori method on the Cuisines column on my dataset.
Cusisine column sample:
   [4] Japanese, Sushi                                                                   
   [5] Japanese, Korean                                                                  
   [6] Chinese                                                                           
   [7] Asian, European                                                                   
   [8] Seafood, Filipino, Asian, European                                                
   [9] European, Asian, Indian                                                           
  [10] Filipino                                                                          
  [11] Filipino, Mexican            

My code:
install.packages("arules") 
 library("arules")

 itemsets <- apriori(dataSet$Cuisines, parameter=list(support=0.02, minlen=1, maxlen=1, target="frequent itemsets"))

However i keep getting:

no method or default for coercing “factor” to “transactions”

What goes wrong in here?
Is it illogical to use Apriori method on this column in my dataset?
If yes, what type of columns should i use the apriori method on?

Possible duplicate of how to convert data.frame to transactions for arules

You have to convert your data to transaction type:
dats <- strsplit(as.character(dats$Cuisines),',',fixed=T) # split by comma    
trans <- as(dats, "transactions")
inspect(trans)
    items                               
[1] { Sushi,Japanese}                   
[2] { Korean,Japanese}                  
[3] {Chinese}                           
[4] { European,Asian}                   
[5] { Asian, European, Filipino,Seafood}
[6] { Asian, Indian,European}           
[7] {Filipino}                          
[8] { Mexican,Filipino}

Then you can do apriori:
itemsets <- apriori(trans, parameter=list(support=0.3))
inspect(itemsets)


With data:
 dats <- read.table(text ="    Cuisines
       [1] 'Japanese, Sushi'                                                                   
       [2] 'Japanese, Korean'                                                                  
       [3] 'Chinese'                                                                           
       [4] 'Asian, European'                                                                   
       [5] 'Seafood, Filipino, Asian, European'                                                
       [6] 'European, Asian, Indian'                                                           
       [7] 'Filipino'                                                                          
       [8] 'Filipino, Mexican' ", header = T)


You probably want to remove the spaces in the item labels with dats <- strsplit(as.character(dats$Cuisines),'\s*,\s*',fixed=T)
