1

I'm using R code in Knime, a platform for data analytics. I take a matrix from a block which reads a table from an xls file. This matrix is called "my_matrix". Then I'd like to applicate the apriori algorithm to three columns of this matrix, but I get the above error. Any ideas?

Please note that "sum(is.na(my_matrix))" has output [1] 0

require(arules)
#require(arulesViz)

#some code to retreive the my_matrix

#my_matrix
my_rows= nrow(my_matrix);
my_cols= ncol(my_matrix);
matrix_temp = my_matrix[,4:5];
matrix_temp = array(c(matrix_temp, my_matrix[,20]), dim=c(my_rows,3))
#matrix_temp
my_matrix = matrix_temp

sum(is.na(my_matrix)) #output: [1] 0

my_transactions = as(my_matrix, "transactions");
summary(my_transactions)

my_matrix is a table in which columns are this type: (String, Integer, Integer, String, String, Integer, Double, Integer, Double, Double, Integer, Double, Double, Integer, Double, Double, Integer, Double, Integer, String). There are 3300 rows in the table.

> my_matrix = as(knime.in, "matrix")
> dput(head(my_matrix, 5))
structure(c("KS", "OH", "NJ", "OH", "OK", "128", "107", "137", 
" 84", " 75", "415", "415", "415", "408", "415", "noIP", "noIP", 
"noIP", "IP", "IP", "Vmail", "Vmail", "noVmail", "noVmail", "noVmail", 
"25", "26", " 0", " 0", " 0", "265.1", "161.6", "243.4", "299.4", 
"166.7", "110", "123", "114", " 71", "113", "45.07", "27.47", 
"41.38", "50.90", "28.34", "197.4", "195.5", "121.2", " 61.9", 
"148.3", " 99", "103", "110", " 88", "122", "16.78", "16.62", 
"10.30", " 5.26", "12.61", "244.7", "254.4", "162.6", "196.9", 
"186.9", " 91", "103", "104", " 89", "121", "11.01", "11.45", 
" 7.32", " 8.86", " 8.41", "10.0", "13.7", "12.2", " 6.6", "10.1", 
" 3", " 3", " 5", " 7", " 3", "2.70", "3.70", "3.29", "1.78", 
"2.73", "1", "1", "0", "2", "3", "notChurning", "notChurning", 
"notChurning", "notChurning", "notChurning"), .Dim = c(5L, 20L
), .Dimnames = list(c("Row0", "Row1", "Row2", "Row3", "Row4"), 
    c("State", "Account length", "Area code", "International plan", 
    "Voice mail plan", "Number vmail messages", "Total day minutes", 
    "Total day calls", "Total day charge", "Total eve minutes", 
    "Total eve calls", "Total eve charge", "Total night minutes", 
    "Total night calls", "Total night charge", "Total intl minutes", 
    "Total intl calls", "Total intl charge", "Customer service calls", 
    "Churn")))
StackUser
  • 587
  • 6
  • 26
  • 1
    What is the error you get? I do not really see a question. Can you provide a sample of my_matrix? – CAFEBABE Jan 03 '16 at 14:34
  • The error is explained in the question itself ("Error in t(as(from, "ngCMatrix")): error evaluating...", @CAFEBABE. Moroever, I have put a sample of my_matrix in my edit – StackUser Jan 03 '16 at 14:53
  • See [here](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) what "reproducible example" means – David Arenburg Jan 03 '16 at 15:14
  • thank you @DavidArenburg, I have just followed your trick to edit my question – StackUser Jan 03 '16 at 16:09
  • @DavidArenburg I see you and others signaled this question as off-topic, but nobody replied me on knime forum, so, please, could you make this question eligible anyway? – StackUser Jan 03 '16 at 16:11
  • I think this question is in it's current form not off-topic anymore. It is now reproducible @DavidArenburg – CAFEBABE Jan 03 '16 at 17:37
  • the problem is that you converted the data frame (knime.in) into a matrix. That step converted all your numbers into string. I will provide a more comp lete answer once the question is open again. From your code I have the gut feeling that you are not really comfortable with r (no-offence). There is also a Knime-node for a priori which might be easier to use. – CAFEBABE Jan 03 '16 at 17:39
  • I already voted to reopen long ago. But I'm only one out of five needed votes. – David Arenburg Jan 03 '16 at 17:47
  • @CAFEBABE I'm quite new to R, so no problem. Anyway, I'd like to make some plots using arulesViz. That's why I'm using R instead of Knime nodes. Anyway, I also have to practice R for the reason you just said :) – StackUser Jan 03 '16 at 18:13
  • @RichardScriven, could you vote to reopen? – StackUser Jan 03 '16 at 22:47
  • @BarghavRao, could you vote to reopen this question? – StackUser Jan 03 '16 at 22:48
  • @AvinashRaj, could you vote to reopen this question? – StackUser Jan 03 '16 at 22:48
  • @Tushar, could you vote to reopen this question? – StackUser Jan 03 '16 at 22:48

0 Answers0