converting s4 object to data frame or list issue in r
<p>i've been trying to implement <code>apriori algorithm</code> to my database in r . as i am doing this , i realized that apriori algorithm returns s4 object . actually it's not a problem if i hadn't wanted to write results to database.</p>

<p>i started to write my r code like this ;
at first i load packages releated to my analysis</p>

<pre><code>library(DBI)
library(rJava)
library(RJDBC)
library(Matrix)
library(grid)
library(arules)
library(arulesViz)

getwd()
setwd("D:/R")
getwd()

jdbcDriver&lt;-JDBC(driverClass = "oracle.jdbc.OracleDriver",classPath = "D:/R/ojdbc6.jar")
jdbcConnection&lt;-dbConnect(jdbcDriver,"jdbc:oracle:ip:port","user","pass")
ana_sorgu&lt;- dbGetQuery(jdbcConnection,"SELECT action_id, product_cat FROM table")
urunler&lt;-dbGetQuery(jdbcConnection,"select distinct product_cat from product_cat")

i &lt;- split(ana_sorgu$PRODUCT_CAT,ana_sorgu$ACTION_ID)
txn &lt;- as(i, "transactions")

sorgu2&lt;-as.list(urunler$PRODUCT_CAT)

for(row2 in 1:nrow(urunler)) {
    basket_rules&lt;-apriori(data=txn, parameter=list(supp=0.001,conf = 0.4), appearance = list(default="lhs",rhs=sorgu2[[row2]]))
    deneme&lt;-inspect(basket_rules)#i guess that something has to be changed to write here releated to next for loop but i can't
    for(row in 1:length(basket_rules)) {
        jdbcDriver2&lt;-JDBC(driverClass = "oracle.jdbc.OracleDriver",classPath = "D:/R/ojdbc6.jar", identifier.quote = "\"")
        jdbcConnection2&lt;-dbConnect(jdbcDriver,"jdbc:oracle:ip:port","user","pass")
        sorgu &lt;- paste0("insert into market_basket_analysis_3 (lhs,rhs,support,confidence,lift) values ('",deneme$lhs[[row]],"','",deneme$rhs[[row]],"','",deneme$support[[row]],"','",deneme$confidence[[row]],"','",deneme$lift[[row]],"')")
        print(sorgu)
        result&lt;-dbSendUpdate(jdbcConnection2,sorgu)
        dbDisconnect(jdbcConnection2)
}}
</code></pre>

<p>i have created variable that called sorgu2 to make my analysis dynamiccally product category by product category so i implemented urunler$PRODUCT_CAT in as.list().Therefore i can use it in rhs that in first for loop.</p>

<p>Finally when i execute this cod it returns;</p>

<pre><code>Apriori
Parameter specification:
confidence minval smax arem  aval originalSupport support minlen maxlen target   ext
    0.4    0.1    1 none FALSE            TRUE   0.001      1     10  rules FALSE
Algorithmic control:
filter tree heap memopt load sort verbose
0.1 TRUE TRUE  FALSE TRUE    2    TRUE

Absolute minimum support count: 854

set item appearances ...[1 item(s)] done [0.00s].
set transactions ...[793 item(s), 854614 transaction(s)] done [0.34s].
sorting and recoding items ... [350 item(s)] done [0.05s].
creating transaction tree ... done [0.99s].
checking subsets of size 1 2 3 4 done [0.20s].
writing ... [0 rule(s)] done [0.00s].
creating S4 object  ... done [0.12s].
[1] "insert into market_basket_analysis_3 (lhs,rhs,support,confidence,lift) values ('','','','','')"
[1] "insert into market_basket_analysis_3 (lhs,rhs,support,confidence,lift) values ('','','','','')"
Apriori

Parameter specification:
 confidence minval smax arem  aval originalSupport support minlen maxlen target   ext
    0.4    0.1    1 none FALSE            TRUE   0.001      1     10  rules FALSE
Algorithmic control:
 filter tree heap memopt load sort verbose
0.1 TRUE TRUE  FALSE TRUE    2    TRUE

Absolute minimum support count: 854

set item appearances ...[1 item(s)] done [0.00s].
set transactions ...[793 item(s), 854614 transaction(s)] done [0.33s].
sorting and recoding items ... [350 item(s)] done [0.05s].
creating transaction tree ... done [0.98s].
checking subsets of size 1 2 3 4 done [0.20s].
writing ... [0 rule(s)] done [0.00s].
creating S4 object  ... done [0.12s].
[1] "insert into market_basket_analysis_3 (lhs,rhs,support,confidence,lift) values ('','','','','')"
[1] "insert into market_basket_analysis_3 (lhs,rhs,support,confidence,lift) values ('','','','','')"
Error in asMethod(object) : 
NISASTA PATATES ALGR2 is an unknown item label
</code></pre>

<p>where did i do wrong? thanks in advance.</p>