re1071

countpattern: invalid 'nrow' value (too large or NA)


I'm having difficulty applying the countpattern function from e1071 package. I aim to find binary patterns and count them. My data consists of a large matrix (1117200 elements, 9.6 MB) with 114 columns and 9800 rows. When applied the function, I keep receiving the following error message:

Error in matrix(0, 2^nvar, nvar) : invalid 'nrow' value (too large or NA)

I was testing the function increasing gradually the number of columns from my data, and it worked until use ~19 columns (just a small part of my 114 columns in total). More than that, it produced an Error.

So, the solution might be to find a more efficient function/algorithm than this function to find the binary patterns. However, before moving on, I wanted to ask if there is a way to contour this situation using the countpattern function?

Thanks for your time!

As requested by @slamballais, a data samples is presented as following,

data_sample <- rbind(c(1,1,1,0,1,0,1,1,0,1,0), c(1,0,0,1,1,1,9,1,0,0,1), c(1,0,0,0,0,1,0,1,1,0,0), c(0,1,1,0,0,0,0,0,1,1,1), c(1,1,1,0,0,1,1,0,1,1,0))


Solution

  • Does

    table(apply(data_sample,1, paste,collapse=""))
    

    work?