循环通过子数据R

时间:2017-11-06 15:47:58

标签: r subset

计划为每个Label计算按地区划分的平均值,并将其保存到新数据框。由于我有一个庞大的数据集,我需要一个循环 - 任何帮助都将非常感激。

structure(list(Label = structure(c(1L, 2L, 1L, 1L, 2L, 2L, 2L, 
1L), .Label = c("a", "b"), class = "factor"), Region = structure(c(3L, 
1L, 1L, 1L, 1L, 2L, 2L, 3L), .Label = c("EUR", "GLB", "UK"), class = "factor"), 
Value = c(-6, 17, 26, -37, 44, -22, 15, 12)), .Names = c("Label", 
"Region", "Value"), row.names = c(NA, -8L), class = "data.frame")

0 个答案:

没有答案