Ozone Solar.R Wind TempC Month Day
1 41 190 7.4 19.44444 5 1
2 36 118 8.0 22.22222 5 2
3 12 149 12.6 23.33333 5 3
4 18 313 11.5 16.66667 5 4
5 NA NA 14.3 13.33333 5 5
6 28 NA 14.9 18.88889 5 6
如何找到平均温度最高的月份?
答案 0 :(得分:0)
如果你想到客户端解决方案,实时,我认为你应该使用AngularJS进行实时计算,否则使用你的后端语言/数据库。
答案 1 :(得分:0)
尝试
names(with(df, which.max(tapply(TempC, Month, FUN=mean, na.rm=TRUE))))
df <- structure(list(Ozone = c(41L, 36L, 12L, 18L, NA, 28L, 41L, 36L,
12L, 18L, NA, 28L), Solar.R = c(190L, 118L, 149L, 313L, NA, NA,
190L, 118L, 149L, 313L, NA, NA), Wind = c(7.4, 8, 12.6, 11.5,
14.3, 14.9, 7.4, 8, 12.6, 11.5, 14.3, 14.9), TempC = c(19.44444,
22.22222, 23.33333, 16.66667, 13.33333, 18.88889, 19.54444, 22.32222,
24.33333, 18.66667, 19.33333, 20.88889), Month = c(5L, 5L, 5L,
5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L), Day = c(1L, 2L, 3L, 4L,
5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L)), .Names = c("Ozone", "Solar.R",
"Wind", "TempC", "Month", "Day"), class = "data.frame", row.names = c("1",
"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"))