Running examples in ‘rifttable-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: rifttable
> ### Title: Results Tables for Epidemiology
> ### Aliases: rifttable
> 
> ### ** Examples
> 
> # Load 'cancer' dataset from survival package (Used in all examples)
> data(cancer, package = "survival")
> 
> # The exposure (here, 'sex') must be categorical
> cancer <- cancer |>
+   tibble::as_tibble() |>
+   dplyr::mutate(
+     sex = factor(
+       sex,
+       levels = 1:2,
+       labels = c("Male", "Female")
+     ),
+     time = time / 365.25,
+     status = status - 1
+   )
> 
> 
> # Example 1: Binary outcomes (use 'outcome' variable)
> # Set table design
> design1 <- tibble::tibble(
+   label = c(
+     "Outcomes",
+     "Total",
+     "Outcomes/Total",
+     "Risk",
+     "Risk (CI)",
+     "Outcomes (Risk)",
+     "Outcomes/Total (Risk)",
+     "RR",
+     "RD"
+   )
+ ) |>
+   dplyr::mutate(
+     type = label,
+     exposure = "sex",
+     outcome = "status"
+   )
> 
> # Generate rifttable
> rifttable(
+   design = design1,
+   data = cancer
+ )
# A tibble: 9 × 3
  sex                   Male              Female              
  <chr>                 <chr>             <chr>               
1 Outcomes              112               53                  
2 Total                 138               90                  
3 Outcomes/Total        112/138           53/90               
4 Risk                  0.81              0.59                
5 Risk (CI)             0.81 (0.74, 0.87) 0.59 (0.49, 0.68)   
6 Outcomes (Risk)       112 (0.81)        53 (0.59)           
7 Outcomes/Total (Risk) 112/138 (0.81)    53/90 (0.59)        
8 RR                    1 (reference)     0.73 (0.60, 0.88)   
9 RD                    0 (reference)     -0.22 (-0.34, -0.10)
> 
> # Use 'design' as columns (selecting RR and RD only)
> rifttable(
+   design = design1 |>
+     dplyr::filter(label %in% c("RR", "RD")),
+   data = cancer,
+   layout = "cols"
+ )
# A tibble: 2 × 3
  sex    RR                RD                  
  <chr>  <chr>             <chr>               
1 Male   1 (reference)     0 (reference)       
2 Female 0.73 (0.60, 0.88) -0.22 (-0.34, -0.10)
> 
> 
> # Example 2: Survival outcomes (use 'time' and 'event'),
> #   with an effect modifier and a confounder
> # Set table design
> design2 <- tibble::tribble(
+   # Elements that vary by row:
+   ~label,                       ~stratum, ~confounders, ~type,
+   "**Overall**",                NULL,     "",           "blank",
+   "  Events",                   NULL,     "",           "events",
+   "  Person-years",             NULL,     "",           "time",
+   "  Rate/1000 py (95% CI)",    NULL,     "",           "rate (ci)",
+   "  Unadjusted HR (95% CI)",   NULL,     "",           "hr",
+   "  Age-adjusted HR (95% CI)", NULL,     "+ age",      "hr",
+   "",                           NULL,     "",           "blank",
+   "**Stratified models**",      NULL,     "",           "",
+   "*ECOG PS1* (events/N)",      1,        "",           "events/total",
+   "  Unadjusted",               1,        "",           "hr",
+   "  Age-adjusted",             1,        "+ age",      "hr",
+   "*ECOG PS2* (events/N)",      2,        "",           "events/total",
+   "  Unadjusted",               2,        "",           "hr",
+   "  Age-adjusted",             2,        "+ age",      "hr",
+   "",                           NULL,     "",           "",
+   "**Joint model**, age-adj.",  NULL,     "",           "",
+   "  ECOG PS1",                 1,        "+ age",      "hr_joint",
+   "  ECOG PS2",                 2,        "+ age",      "hr_joint"
+ ) |>
+   # Elements that are the same for all rows:
+   dplyr::mutate(
+     exposure = "sex",
+     event = "status",
+     time = "time",
+     effect_modifier = "ph.ecog"
+   )
> 
> # Generate rifttable
> rifttable(
+   design = design2,
+   data = cancer |>
+     dplyr::filter(ph.ecog %in% 1:2)
+ )
# A tibble: 18 × 3
   sex                          Male                     Female                 
   <chr>                        <chr>                    <chr>                  
 1 "**Overall**"                ""                       ""                     
 2 "  Events"                   "82"                     "44"                   
 3 "  Person-years"             "70"                     "59"                   
 4 "  Rate/1000 py (95% CI)"    "1164.8 (938.1, 1446.3)" "746.7 (555.7, 1003.4)"
 5 "  Unadjusted HR (95% CI)"   "1 (reference)"          "0.60 (0.41, 0.86)"    
 6 "  Age-adjusted HR (95% CI)" "1 (reference)"          "0.60 (0.41, 0.86)"    
 7 ""                           ""                       ""                     
 8 "**Stratified models**"      ""                       ""                     
 9 "*ECOG PS1* (events/N)"      "54/71"                  "28/42"                
10 "  Unadjusted"               "1 (reference)"          "0.53 (0.33, 0.85)"    
11 "  Age-adjusted"             "1 (reference)"          "0.53 (0.33, 0.85)"    
12 "*ECOG PS2* (events/N)"      "28/29"                  "16/21"                
13 "  Unadjusted"               "1 (reference)"          "0.70 (0.37, 1.30)"    
14 "  Age-adjusted"             "1 (reference)"          "0.68 (0.34, 1.36)"    
15 ""                           ""                       ""                     
16 "**Joint model**, age-adj."  ""                       ""                     
17 "  ECOG PS1"                 "1 (reference)"          "0.55 (0.35, 0.88)"    
18 "  ECOG PS2"                 "1.54 (0.98, 2.44)"      "1.10 (0.62, 1.98)"    
> 
> 
> # Example 3: Get two estimates using 'type' and 'type2'
> design3 <- tibble::tribble(
+   ~label,     ~stratum, ~type,          ~type2,
+   "ECOG PS1", 1,        "events/total", "hr",
+   "ECOG PS2", 2,        "events/total", "hr"
+ ) |>
+   dplyr::mutate(
+     exposure = "sex",
+     event = "status",
+     time = "time",
+     confounders = "+ age",
+     effect_modifier = "ph.ecog"
+   )
> 
> rifttable(
+   design = design3,
+   data = cancer |>
+     dplyr::filter(ph.ecog %in% 1:2)
+ )
# A tibble: 4 × 3
  sex        Male          Female           
  <chr>      <chr>         <chr>            
1 "ECOG PS1" 54/71         28/42            
2 ""         1 (reference) 0.53 (0.33, 0.85)
3 "ECOG PS2" 28/29         16/21            
4 ""         1 (reference) 0.68 (0.34, 1.36)
> 
> rifttable(
+   design = design3,
+   data = cancer |>
+     dplyr::filter(ph.ecog %in% 1:2),
+   layout = "cols",
+   type2_layout = "cols"
+ )
# A tibble: 2 × 5
  sex    `ECOG PS1` `ECOG PS1 `       `ECOG PS2` `ECOG PS2 `      
  <chr>  <chr>      <chr>             <chr>      <chr>            
1 Male   54/71      1 (reference)     28/29      1 (reference)    
2 Female 28/42      0.53 (0.33, 0.85) 16/21      0.68 (0.34, 1.36)
> 
> 
> # Example 4: Continuous outcomes (use 'outcome' variable);
> # request rounding to 1 decimal digit in some cases;
> # add continuous trend (slope per one unit of the 'trend' variable)
> tibble::tribble(
+   ~label,                   ~stratum, ~type,        ~digits,
+   "Marginal mean (95% CI)", NULL,     "mean (ci)",  1,
+   "  Male",                 "Male",   "mean",       NA,
+   "  Female",               "Female", "mean",       NA,
+   "",                       NULL,     "",           NA,
+   "Stratified model",       NULL,     "",           NA,
+   "  Male",                 "Male",   "diff",       1,
+   "  Female",               "Female", "diff",       1,
+   "",                       NULL,     "",           NA,
+   "Joint model",            NULL,     "",           NA,
+   "  Male",                 "Male",   "diff_joint", NA,
+   "  Female",               "Female", "diff_joint", NA
+ ) |>
+   dplyr::mutate(
+     exposure = "ph.ecog_factor",
+     trend = "ph.ecog",
+     outcome = "age",
+     effect_modifier = "sex"
+   ) |>
+   rifttable(
+     data = cancer |>
+       dplyr::filter(ph.ecog < 3) |>
+       dplyr::mutate(ph.ecog_factor = factor(ph.ecog))
+   )
# A tibble: 11 × 5
   ph.ecog_factor           `0`                   `1`                `2`   Trend
   <chr>                    <chr>                 <chr>              <chr> <chr>
 1 "Marginal mean (95% CI)" "61.2 (58.8, 63.5)"   "61.5 (59.8, 63.1… "66.… ""   
 2 "  Male"                 "63.00"               "62.79"            "65.… ""   
 3 "  Female"               "58.70"               "59.19"            "67.… ""   
 4 ""                       ""                    ""                 ""    ""   
 5 "Stratified model"       ""                    ""                 ""    ""   
 6 "  Male"                 "0 (reference)"       "-0.2 (-3.9, 3.5)" "2.0… "0.9…
 7 "  Female"               "0 (reference)"       "0.5 (-3.5, 4.5)"  "9.2… "4.4…
 8 ""                       ""                    ""                 ""    ""   
 9 "Joint model"            ""                    ""                 ""    ""   
10 "  Male"                 "0 (reference)"       "-0.21 (-3.75, 3.… "2.0… "0.9…
11 "  Female"               "-4.30 (-8.70, 0.11)" "-3.81 (-7.74, 0.… "4.9… "4.3…
> 
> 
> # Example 5: Get formatted output for Example 2
> rifttable(
+   design = design2,
+   data = cancer |>
+     dplyr::filter(ph.ecog %in% 1:2)
+ ) |>
+   rt_gt()
Error in loadNamespace(x) : there is no package called ‘knitr’
Calls: rt_gt ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted