遍历子集对象并将输出存储在r中



我有10个对象命名为output_ens1output_ens10。我想从每个对象中取出一个数据,对其执行算术运算,并将其添加到一个新对象中。我一直在尝试for循环和子集。下面是一个带有my loop

的示例对象
## Values used elsewhere in model output processing
num_sp <- 46  # Enter the number of species modeled
num_steps <- 36 # Enter the number of months modeled
num_ens <- 10 # Enter the number of runs in the ensemble
## example object of same dimensions
output_ens1 <- matrix(data = c(1:11880), ncol = 330, nrow = 36)
hist <- c(1:num_ens)
for (i in hist)
{
hist[i] <- as.name(paste0("output_ens", i))[num_steps,8+num_sp*7]/1000
}

这返回

Error in as.name(paste0("output_ens", i))[num_steps, 8 + num_sp * 7] : 
object of type 'symbol' is not subsettable

我想要num_steps(第36行)和8+num_sp*7(第330行)列值除以1000并添加到对象hist。在这个例子中,值11.88(11880/1000)将被设置为hist[1]。我已经尝试了几次迭代,并且认为我的问题是读取要作为子集的对象的名称。我应该朝哪个方向走?

使用

get(paste0("output_ens", i))