I have never use R ,but now I need import a sparse matrix to do association rule in R
My import data is a sparse matrix like this:
i j x
1 2 3 1
2 3 5 1
3 3 1 1
4 2 5 1
. . . .
. . . .
200000000 . . .
the sparse matrix size is 200,000,000 X 3, the matrix is 200000 X 100000 (big data?)
I want use this data to do association rules in R,
Is use 'Package arules' itemMatrix-class & tidLists-class() ? or others?
And how to do?
I do like this but not work:
channel <- odbcConnect("test")
data<-sqlQuery(channel,"select i,j,x from table") # it's work
(args <- data.frame(data)) # it's work ,print sparse matrix
# i j x
#1 2 3 1
#2 3 5 1
#3 3 1 1
#3 2 5 1
# ....
(Aa <- do.call(sparseMatrix, args)) # it's work ,print sparse Matrix of class "dgCMatrix"
# 200000 X 100000 sparse Matrix of class "dgCMatrix"
# 1 2 3 4 5....
# [1,] . . . . .
# [2,] . . | . |
# [3,] | . . . |
# ....
rules <- apriori(Aa) # it's not work
Error in as(data, "transactions") :
no method or default for coercing “dgCMatrix” to “transactions”
Can use sparse matrix in apriori function?
Maybe I use the wrong package?
Do I need sparse matrix-> matrix->association rule?
or sparse matrix->association rule?