I have the following code:
concept_vectors <- foreach(j = 1:2, .combine=rBind, .packages="Matrix") %do% { Matrix::colMeans(sparseX[1:10,],sparseResult=TRUE) }
which leads to the following error message:
Error in { : no method for coercing this S4 class to a vector
However, if I either remove the sparseResult = TRUE parameter or not use colMeans at all, the code works, even if without colMeans, sparseX is still an S4 object.
If I replaced rBind with rbind2 directly, then I still see the following error:
error calling combine function: <simpleError in .__H__.rbind(deparse.level = 0, x, y): no method for coercing this S4 class to a vector>
Do you know about this workaround?
source share