socialresearchcentre / projectable

Produce table-like objects made up of special metadata-rich column vectors, and project them into two dimensions.
https://socialresearchcentre.github.io/projectable
GNU General Public License v3.0
3 stars 0 forks source link

Weighted frequencies #10

Closed kinto-b closed 3 years ago

kinto-b commented 4 years ago

Currently you can do weighted frequencies with

col_freq(WEIGHT * FITIN %in% 1, WEIGHT)

I sort of like that approach, but possibly having a dedicated argument would make things more usable.

More importantly though, there's no way to stipulate weights when using spec_col_freq

gorcha commented 4 years ago

Yeah maybe just a "weight" argument that defaults to 1 and multiplies both the base and vals? (and is ignored when summarised)

kinto-b commented 4 years ago

Yeah, I like that -- do you think do that for col_freq and spec_col_freq or just the latter?

I don't mind the API for col_freq as it's a bit more transparent what's going on than would be with a separate argument, but documenting that behaviour would be slightly more annoying

gorcha commented 4 years ago

I tihnk for col_freq as well, it's a bit cleaner from a usability perspective, so you can do things like:

Unweighted = col_freq(x %in% 1, x %in% 0:1),
Weighted = col_freq(x %in% 1, x %in% 0:1, weight = wgt),