| estimate_multinomial_rsp {tern} | R Documentation | 
Estimation of proportions per level of factor
Description
Estimate the proportion along with confidence interval of a proportion regarding the level of a factor.
Usage
estimate_multinomial_response(
  lyt,
  var,
  na_str = default_na_str(),
  nested = TRUE,
  ...,
  show_labels = "hidden",
  table_names = var,
  .stats = "prop_ci",
  .formats = NULL,
  .labels = NULL,
  .indent_mods = NULL
)
s_length_proportion(x, .N_col, ...)
a_length_proportion(x, .N_col, ...)
Arguments
lyt | 
 (  | 
var | 
 (  | 
na_str | 
 (  | 
nested | 
 (  | 
... | 
 additional arguments for the lower level functions.  | 
show_labels | 
 (  | 
table_names | 
 (  | 
.stats | 
 (  | 
.formats | 
 (named   | 
.labels | 
 (named   | 
.indent_mods | 
 (named   | 
x | 
 (  | 
.N_col | 
 (  | 
Value
-  
estimate_multinomial_response()returns a layout object suitable for passing to further layouting functions, or tortables::build_table(). Adding this function to anrtablelayout will add formatted rows containing the statistics froms_length_proportion()to the table layout. 
-  
s_length_proportion()returns statistics froms_proportion(). 
-  
a_length_proportion()returns the corresponding list with formattedrtables::CellValue(). 
Functions
-  
estimate_multinomial_response(): Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper forrtables::analyze()andrtables::summarize_row_groups(). -  
s_length_proportion(): Statistics function which feeds the length ofxas number of successes, and.N_colas total number of successes and failures intos_proportion(). -  
a_length_proportion(): Formatted analysis function which is used asafuninestimate_multinomial_response(). 
See Also
Relevant description function d_onco_rsp_label().
Examples
library(dplyr)
# Use of the layout creating function.
dta_test <- data.frame(
  USUBJID = paste0("S", 1:12),
  ARM     = factor(rep(LETTERS[1:3], each = 4)),
  AVAL    = c(A = c(1, 1, 1, 1), B = c(0, 0, 1, 1), C = c(0, 0, 0, 0))
) %>% mutate(
  AVALC = factor(AVAL,
    levels = c(0, 1),
    labels = c("Complete Response (CR)", "Partial Response (PR)")
  )
)
lyt <- basic_table() %>%
  split_cols_by("ARM") %>%
  estimate_multinomial_response(var = "AVALC")
tbl <- build_table(lyt, dta_test)
tbl
s_length_proportion(rep("CR", 10), .N_col = 100)
s_length_proportion(factor(character(0)), .N_col = 100)
a_length_proportion(rep("CR", 10), .N_col = 100)
a_length_proportion(factor(character(0)), .N_col = 100)