我正在尝试使用 for 循环来简化以下代码:
a1 <- CreateSeuratObject (raw.data = a1.data)
a2 <- CreateSeuratObject (raw.data = a2.data)
a3 <- ...
我尝试了以下方法:
samples <- c("a1", "a2", "a3")
samples.data <- c("a1.data", "a2.data", "a3.data")
for (i in samples) {
for (j in samples.data) {
i <- CreateSeuratObject(raw.data = j)
}
}
但它返回以下错误:
Error in base::colSums(x, na.rm = na.rm, dims = dims, ...) :
'x' must be an array of at least two dimensions
CreateSeuratObject 函数本质上是尝试读取 samples.data 向量,而不是索引向量中的相应项。我怎样才能解决这个问题?