rtables icon indicating copy to clipboard operation
rtables copied to clipboard

afun in analyze returns column structure

Open waddella opened this issue 3 years ago • 0 comments

It would be good to have values generated by a single function displayed in as column:

s_num <- function(x) {
  list(
    n = length(x),
    mean = mean(x, na.rm = TRUE),
    max = max(x)
  )
}

lyt <- basic_table() %>%
  analyze("Sepal.Length", afun = function(x) {
     in_cols(.list = s_num(x), .names = c("n", "mean", "max"))
  })

build_table(lyt, iris)

should return the following table

                 n            mean        max
-----------------------------------------------
Sepal.Length    150         5.843333      7.9

as per discussion we should look int in_mat and maybe drop in_cols

waddella avatar Dec 14 '21 18:12 waddella