Closed cschwem2er closed 6 years ago
Okay I just tested this with another pc and a Stata dataset here and now, weighting does not work regardless of spelling. I also don't quite understand when nonstandard evaluation is supposed to work with weights and when it is not.
Another test: It also works on the other system when passing the weight variable name as a string, e.g. weight.by = 'weight'
. Whatever version you would prefer to work at the end: if non standard evaluation does not work for all arguments, it would be very helpful if the argument description for grpmean
(and maybe other affected commands?) would include something about that.
At the moment it states "weight.by: Vector of weights that will be applied to weight all cases. Must be a vector of same length as the input vector. Default is NULL, so no weights are used."
This is the same wording as for sjmisc::frq()
, but one cannot pass the weight vector name as string to frq()
. In a perfect and wonderful world, there would only be one consistent way to pass weight arguments for the entire sjverse and all of its functions =D.
This inconsistency had some historical reasons, specifically this issue: https://github.com/strengejacke/sjPlot/commit/5d0be71e3af3aa197a0a832619b7ca7a039fa5b1#diff-9f037f838a5fd66c519d93f0b636b1a3
I needed to treat the weight.by
differently. Now I could revise the method and make it consistent with other function.
Hi,
the following code raises an error:
but this works:
The problem seems to be related to this line: https://github.com/strengejacke/sjstats/blob/aae3248d09198828006d1b6c474687fe8092df79/R/grpmean.R#L68
I'm not sure whether this might affect other functions as well.