【发布时间】:2015-09-10 10:35:29
【问题描述】:
我有以下代码:
concept_vectors <- foreach(j = 1:2, .combine=rBind, .packages="Matrix") %do% {
Matrix::colMeans(sparseX[1:10,],sparseResult=TRUE)
}
这会导致以下错误消息:
Error in { : no method for coercing this S4 class to a vector
但是,如果我删除 'sparseResult=TRUE' 选项,或者根本不使用 colMeans,代码就可以工作,即使没有 colMeans,sparseX 仍然是一个 S4 对象。
如果我直接将 rBind 替换为 rbind2,那么我仍然会看到以下错误:
error calling combine function:
<simpleError in .__H__.rbind(deparse.level = 0, x, y): no method for coercing this S4 class to a vector>
您知道任何解决方法吗?
【问题讨论】:
标签: r matrix sparse-matrix rbind cbind