Skip to contents

[Stable]

Estimate the proportion along with confidence interval of a proportion regarding the level of a factor.

Usage

d_onco_rsp_label(x)

s_length_proportion(x, .N_col, ...)

a_length_proportion(x, .N_col, ...)

estimate_multinomial_response(
  lyt,
  var,
  ...,
  show_labels = "hidden",
  table_names = var,
  .stats = "prop_ci",
  .formats = NULL,
  .labels = NULL,
  .indent_mods = NULL
)

Arguments

x

(character)
the standard oncology code to be described.

.N_col

(count)
row-wise N (row group count) for the group of observations being analyzed (i.e. with no column-based subsetting) that is passed by rtables.

...

additional arguments for the lower level functions.

lyt

(layout)
input layout where analyses will be added to.

var

(string)
single variable name that is passed by rtables when requested by a statistics function.

show_labels

label visibility: one of "default", "visible" and "hidden".

table_names

(character)
this can be customized in case that the same vars are analyzed multiple times, to avoid warnings from rtables.

.stats

(character)
statistics to select for the table.

.formats

(named character or list)
formats for the statistics.

.labels

(named character)
labels for the statistics (without indent).

.indent_mods

(named integer)
indent modifiers for the labels.

Value

See s_proportion() for statistics and additional possible arguments.

Functions

  • d_onco_rsp_label(): Standard Oncology Response

    Describe the oncology response in a standard way.

  • s_length_proportion(): Statistics function which takes the length of the input x and takes that as the number of successes, and the column number .N_col as the total number, and feeds that into s_proportion().

  • a_length_proportion(): Formatted Analysis function which can be further customized by calling rtables::make_afun() on it. It is used as afun in rtables::analyze().

  • estimate_multinomial_response(): Analyze Function which adds the multinomial proportion analysis to the input layout. Note that additional formatting arguments can be used here.

Examples


d_onco_rsp_label(
  c("CR", "PR", "SD", "NON CR/PD", "PD", "NE", "Missing", "<Missing>", "NE/Missing")
)
#>                           CR                           PR 
#>       Complete Response (CR)        Partial Response (PR) 
#>                           SD                    NON CR/PD 
#>          Stable Disease (SD) Non-CR or Non-PD (NON CR/PD) 
#>                           PD                           NE 
#>     Progressive Disease (PD)           Not Evaluable (NE) 
#>                      Missing                    <Missing> 
#>                      Missing                    <Missing> 
#>                   NE/Missing 
#>       Missing or unevaluable 
#> 9 Levels: <Missing> Complete Response (CR) Missing ... Stable Disease (SD)

# Adding some values not considered in d_onco_rsp_label

d_onco_rsp_label(
  c("CR", "PR", "hello", "hi")
)
#>                     CR                     PR                  hello 
#> Complete Response (CR)  Partial Response (PR)                  hello 
#>                     hi 
#>                     hi 
#> Levels: Complete Response (CR) Partial Response (PR) hello hi
s_length_proportion(rep("CR", 10), .N_col = 100)
#> $n_prop
#> [1] 10.0  0.1
#> attr(,"label")
#> [1] "Responders"
#> 
#> $prop_ci
#> [1]  3.620108 16.379892
#> attr(,"label")
#> [1] "95% CI (Wald, with correction)"
#> 
s_length_proportion(factor(character(0)), .N_col = 100)
#> $n_prop
#> [1] 0 0
#> attr(,"label")
#> [1] "Responders"
#> 
#> $prop_ci
#> [1] 0.0 0.5
#> attr(,"label")
#> [1] "95% CI (Wald, with correction)"
#> 
a_length_proportion(rep("CR", 10), .N_col = 100)
#> RowsVerticalSection (in_rows) object print method:
#> ----------------------------
#>   row_name formatted_cell indent_mod                      row_label
#> 1   n_prop     10 (10.0%)          0                     Responders
#> 2  prop_ci  (3.62, 16.38)          0 95% CI (Wald, with correction)
a_length_proportion(factor(character(0)), .N_col = 100)
#> RowsVerticalSection (in_rows) object print method:
#> ----------------------------
#>   row_name formatted_cell indent_mod                      row_label
#> 1   n_prop       0 (0.0%)          0                     Responders
#> 2  prop_ci   (0.00, 0.50)          0 95% CI (Wald, with correction)

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)

html <- as_html(tbl)
html
#> <div class="rtables-all-parts-block rtables-container">
#>   <table class="table table-condensed table-hover">
#>     <tr>
#>       <th style="white-space:pre;"></th>
#>       <th class="text-center">A</th>
#>       <th class="text-center">B</th>
#>       <th class="text-center">C</th>
#>     </tr>
#>     <tr>
#>       <td class="text-left">Complete Response (CR)</td>
#>       <td class="text-center">0 (0.0%)</td>
#>       <td class="text-center">2 (50.0%)</td>
#>       <td class="text-center">4 (100.0%)</td>
#>     </tr>
#>     <tr>
#>       <td class="text-left" style="padding-left: 3ch">95% CI (Wald, with correction)</td>
#>       <td class="text-center">(0.00, 12.50)</td>
#>       <td class="text-center">(0.00, 100.00)</td>
#>       <td class="text-center">(87.50, 100.00)</td>
#>     </tr>
#>     <tr>
#>       <td class="text-left">Partial Response (PR)</td>
#>       <td class="text-center">4 (100.0%)</td>
#>       <td class="text-center">2 (50.0%)</td>
#>       <td class="text-center">0 (0.0%)</td>
#>     </tr>
#>     <tr>
#>       <td class="text-left" style="padding-left: 3ch">95% CI (Wald, with correction)</td>
#>       <td class="text-center">(87.50, 100.00)</td>
#>       <td class="text-center">(0.00, 100.00)</td>
#>       <td class="text-center">(0.00, 12.50)</td>
#>     </tr>
#>     <caption style="caption-side:top;"><div class="rtables-titles-block rtables-container">
#>         <div class="rtables-main-titles-block rtables-container">
#>           <p class="rtables-main-title"></p>
#>         </div>
#>         <div class="rtables-subtitles-block rtables-container"></div>
#>       </div>
#>     </caption>
#>   </table>
#>   <div class="rtables-footers-block rtables-container"></div>
#> </div>
if (FALSE) {
Viewer(html)
}