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

Add `.format` argument to `prj_project()` #31

Open kinto-b opened 2 years ago

kinto-b commented 2 years ago

@paddytobias You can turn off rounding by setting digits=NULL. Try

prj_project(
  dat, list(
    `V-Shaped` = c(p = "{srcreporting::dec_dig3(p, 2)} ({n})"),
    `Not V-shaped` = c(p = "{srcreporting::dec_dig3(p, 2)} ({n})")
  ), .digits = NULL
)

I added rounding as a default because I found myself writing "{round(p, 2)}" literally every time I did a projection. On net I think it saves more typing having the default this way rather than having .digits=NULL by default.

One thing that would be neat though is to deprecate the .digits argument and replace with a .format argument which accepts a formatting function (i.e. a one place function that accepts a string and returns a string). By default .format = round_transformer but then you could write .format = srcreporting::dec_dig3

Originally posted by @kinto-b in https://github.com/socialresearchcentre/projectable/issues/30#issuecomment-1139260506