rtables
rtables copied to clipboard
afun in analyze returns column structure
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