避免在R

时间:2018-02-15 16:37:10

标签: r

假设我们有这些对象:

distM_ref1_matrix <- dist(cbind(distM_ref1$x, distM_ref1$y))
distM_ref2_matrix <- dist(cbind(distM_ref2$x, distM_ref2$y))
distM_ref3_matrix <- dist(cbind(distM_ref3$x, distM_ref3$y))
distM_ref4_matrix <- dist(cbind(distM_ref4$x, distM_ref4$y))
distM_ref5_matrix <- dist(cbind(distM_ref5$x, distM_ref5$y))
distM_ref6_matrix <- dist(cbind(distM_ref6$x, distM_ref6$y))
distM_ref7_matrix <- dist(cbind(distM_ref7$x, distM_ref7$y))
distM_ref8_matrix <- dist(cbind(distM_ref8$x, distM_ref8$y))
distM_ref9_matrix <- dist(cbind(distM_ref9$x, distM_ref9$y))

我有两个问题:

  1. 如何通过一行自动创建所有这些对象来保存代码?考虑我确实有大量的等效对象,而不仅仅是示例中的9个。
  2. 如何同时计算mean value of all these objects
  3. 我认为第二个问题的答案在某种程度上就像这个代码:

    mean(c(distM_ref[1:9]_matrix))
    

0 个答案:

没有答案