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

Revise `project_table()` API #3

Closed kinto-b closed 4 years ago

kinto-b commented 4 years ago

The output of set_table() should always contain rows and row_spanner columns.

We shouldn't have to specify what to do with these. Thus, we shouldn't have to write

set_table(
  mtcars,
  .rows = list(Cylinders = cyl), # row_spanner -> "cyl" and rows -> "cyl %in% 4", ...
  .cols = list(
    vshaped = encol_freq(vs %in% 1, mtcars$vs %in% 1),
    non_vshaped = encol_freq(vs %in% 0, mtcars$vs %in% 1)
  )
) %>%
  project_table(
    list(
      rows = "identity", #<<<<<<<<<<<<<< Remove this
      row_spanner = "identity", #<<<<<<<<<<<< Remove this
      vshaped = "proportion"
    )
  )

Additionally, the function signature should be project_table <- function(.data, ...) , and the ... should take glue-style specifications, like this:

project_table(.data = my_proj,
  some_col = "{proportion} ({little_n})" # "some_col" without a spanner,
  other_col = c(Proportion = "{proportion}", Count = "{sample}", CI = "{ci_lower} - {ci_upper}"), # "Proportion", "Count" and "CI" spanned by "other_col"
)