我严格需要使用 summarise_at 来计算加权平均值,权重基于另一列的值
df %>% summarise_at(.vars = vars(FACTOR,tv:`smart tv/console`),
.funs = weighted.mean, w=INVESTMENT, na.rm=TRUE)
它总是显示错误:'INVESTMENT' is not found.
然后我尝试了:
df %>%summarise_at(.vars = vars(FACTOR,tv:`smart tv/console`),
.funs = weighted.mean, w=vars(INVESTMENT), na.rm=TRUE)
但在这种情况下: Evaluation error: 'x' and 'w' must have the same length.
为什么是这样?我做错什么了吗?你有解决这个问题的提示吗?谢谢