sparseVector error involving checkSort and is.unsorted(i) in R

Viewed 20

I'm trying to run the sparseVector() function on a fairly large vector in a list. I extracted the nonzero counts into a separate vector so I can use it in the function.

# dataset[[2]] is the 29634 element vector I want to make into a sparse vector
nonzero_vector <- which(dataset[[2]] != 0)

However, when I try to run the sparseVector() function, I get an error that I cannot find anywhere on the Internet and seems to be quite rare.

sparseVector(dataset[[2]], nonzero_vector, 29634)
Error in if (checkSort && is.unsorted(i)) { : 
  missing value where TRUE/FALSE needed

Does anyone have any ideas on what this error is and how to fix it?

0 Answers
Related