Error in t(as(from, "ngCMatrix")) : error in evaluating the argument 'x' in selecting a method for function 't': Error in asM

I have put the code below inside the node R learner, after xls reader. I read my dataset with xls reader, then I'd like to use apriori algorithm on three columns of my dataset (the fourth, the fifth and the twentieth, which are of type String). But, when the node R Learner puts those columns in a new matrix and transform them into transactions, I get the following error:

Error in t(as(from, "ngCMatrix")) :    error in evaluating the argument 'x' in selecting a method for function 't': Error in asM

 

require(arules)
#require(arulesViz)
my_matrix= as(knime.in,"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)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.