I strictly need to use the summarise_at to compute a weighted mean, with weights based on the values of another column
df %>% summarise_at(.vars = vars(FACTOR,tv:`smart tv/console`),
.funs = weighted.mean, w=INVESTMENT, na.rm=TRUE)
It always shows the error: 'INVESTMENT' is not found.
I then tried with:
df %>%summarise_at(.vars = vars(FACTOR,tv:`smart tv/console`),
.funs = weighted.mean, w=vars(INVESTMENT), na.rm=TRUE)
But in this case : Evaluation error: 'x' and 'w' must have the same length.
Why is this? Am I doing anything wrong? Do you have hints to solve this issue? Thanks