I want to create a weighted mean of a dichotomous variables (0 or 1) using expss packages. AND the results will be presented in percentage. These dichotomous variables contain missing values.
fisrt of all, i create a function :
tableau = function (Q, banner,titre) {
banner <- df %>%
tab_cols(a2,a3)
eval.parent(substitute(
{
banner %>%
tab_cells (list(Q)) %>%
tab_weight(weighting_var) %>%
tab_stat_fun("%" = function (x) mean(x,na.rm = TRUE)*100) %>%
tab_pivot() %>%
drop_empty_columns() %>%
tab_transpose() %>%
set_caption(titre) #%>%
# custom_format()
}
))
}
When i use this function:
tableau(list(i1.3_1,i1.3_2,i1.3_3,i1.3_4,i1.3_5,i1.3_6),banner,'TABLE 1')
i get this message :
`weight` is provided but function`%` doesn't have formal `weight` argument
how can I modify my function to make sure that the results are weighting?