How to average score from different elements
This question already has an answer here:
我们可以尝试
library(data.table)
setDT(data)[, list(avg = mean(Score)), by = AD]
library(data.table)
dt <- data.table(ur_data)
dt[, lapply(.SD, mean), by = "AD"]
I'd recommend the dplyr
package.
require(dplyr)
data %>%
group_by(AD) %>%
summarize(avg = mean(Score))
Is that what you're looking for?
链接地址: http://www.djcxy.com/p/24882.html上一篇: 如何用R数据框中的零代替NA值?
下一篇: 如何平均来自不同元素的分数