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

> ### Name: as_kable.tablet
> ### Title: Coerce Tablet to Kable
> ### Aliases: as_kable.tablet
> 
> ### ** Examples
> 
> library(boot)
> library(dplyr)

Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

    filter, lag

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union

> library(magrittr)
> library(haven)
> library(yamlet)

Attaching package: ‘yamlet’

The following object is masked from ‘package:stats’:

    filter

> library(spork)
> melanoma %>%
+   select(-time, -year) %>%
+   mutate(sex = factor(sex), ulcer = factor(ulcer)) %>%
+   group_by(status) %>%
+   tablet %>%
+   as_kable
<table>
 <thead>
  <tr>
   <th style="text-align:left;">   </th>
   <th style="text-align:left;"> 1<br>(N = 57) </th>
   <th style="text-align:left;"> 2<br>(N = 134) </th>
   <th style="text-align:left;"> 3<br>(N = 14) </th>
   <th style="text-align:left;"> All<br>(N = 205) </th>
  </tr>
 </thead>
<tbody>
  <tr grouplength="2"><td colspan="5" style="border-bottom: 1px solid;"><strong>sex</strong></td></tr>
<tr>
   <td style="text-align:left;padding-left: 2em;" indentlevel="1"> 0 </td>
   <td style="text-align:left;"> 28 (49.1%) </td>
   <td style="text-align:left;"> 91 (67.9%) </td>
   <td style="text-align:left;"> 7 (50%) </td>
   <td style="text-align:left;"> 126 (61.5%) </td>
  </tr>
  <tr>
   <td style="text-align:left;padding-left: 2em;" indentlevel="1"> 1 </td>
   <td style="text-align:left;"> 29 (50.9%) </td>
   <td style="text-align:left;"> 43 (32.1%) </td>
   <td style="text-align:left;"> 7 (50%) </td>
   <td style="text-align:left;"> 79 (38.5%) </td>
  </tr>
  <tr grouplength="2"><td colspan="5" style="border-bottom: 1px solid;"><strong>age</strong></td></tr>
<tr>
   <td style="text-align:left;padding-left: 2em;" indentlevel="1"> Mean (SD) </td>
   <td style="text-align:left;"> 55.1 (17.9) </td>
   <td style="text-align:left;"> 50 (15.9) </td>
   <td style="text-align:left;"> 65.3 (10.9) </td>
   <td style="text-align:left;"> 52.5 (16.7) </td>
  </tr>
  <tr>
   <td style="text-align:left;padding-left: 2em;" indentlevel="1"> Median (range) </td>
   <td style="text-align:left;"> 56 (14, 95) </td>
   <td style="text-align:left;"> 52 (4, 84) </td>
   <td style="text-align:left;"> 65 (49, 86) </td>
   <td style="text-align:left;"> 54 (4, 95) </td>
  </tr>
  <tr grouplength="2"><td colspan="5" style="border-bottom: 1px solid;"><strong>thickness</strong></td></tr>
<tr>
   <td style="text-align:left;padding-left: 2em;" indentlevel="1"> Mean (SD) </td>
   <td style="text-align:left;"> 4.31 (3.57) </td>
   <td style="text-align:left;"> 2.24 (2.33) </td>
   <td style="text-align:left;"> 3.72 (3.63) </td>
   <td style="text-align:left;"> 2.92 (2.96) </td>
  </tr>
  <tr>
   <td style="text-align:left;padding-left: 2em;" indentlevel="1"> Median (range) </td>
   <td style="text-align:left;"> 3.54 (0.32, 17.4) </td>
   <td style="text-align:left;"> 1.36 (0.1, 12.9) </td>
   <td style="text-align:left;"> 2.26 (0.16, 12.6) </td>
   <td style="text-align:left;"> 1.94 (0.1, 17.4) </td>
  </tr>
  <tr grouplength="2"><td colspan="5" style="border-bottom: 1px solid;"><strong>ulcer</strong></td></tr>
<tr>
   <td style="text-align:left;padding-left: 2em;" indentlevel="1"> 0 </td>
   <td style="text-align:left;"> 16 (28.1%) </td>
   <td style="text-align:left;"> 92 (68.7%) </td>
   <td style="text-align:left;"> 7 (50%) </td>
   <td style="text-align:left;"> 115 (56.1%) </td>
  </tr>
  <tr>
   <td style="text-align:left;padding-left: 2em;" indentlevel="1"> 1 </td>
   <td style="text-align:left;"> 41 (71.9%) </td>
   <td style="text-align:left;"> 42 (31.3%) </td>
   <td style="text-align:left;"> 7 (50%) </td>
   <td style="text-align:left;"> 90 (43.9%) </td>
  </tr>
</tbody>
</table>> 
> x <- system.file(package = 'tablet', 'shiny-examples/mesa/data/adsl.sas7bdat')
> x %<>% read_sas %>% data.frame
> decorations(x) # note weight in pounds
- anyaefl
 - label: Any TEAEs
 - format.sas: $
- seraefl
 - label: Serious TEAEs
 - format.sas: $
- agegr
 - label: Age Categories
 - format.sas: $
- age
 - label: Age (years)
 - format.sas: BEST
- diagdur
 - label: Duration of Disease (years)
 - format.sas: BEST
- weight
 - label: Weight (lb)
 - format.sas: BEST
- sex
 - label: Gender
 - format.sas: $
- asex
 - label: Gender
 - format.sas: $
- studyid
 - label: studyid
 - format.sas: $
- usubjid
 - label: usubjid
 - format.sas: $
- saffl
 - label: saffl
 - format.sas: $
- trt01a
 - label: trt01a
 - format.sas: $
- trt01aa
 - label: trt01aa
 - format.sas: $
> x %<>% mutate(weight = signif(digits = 3, weight * 2.2))
> 
> # calculate BMI by assuming all males are 1.75 m, all females 1.63 cm
> x %<>% mutate(height = ifelse(sex == 'F', 1.63, 1.75))
> x %<>% mutate(bmi = signif(digits = 3, weight / (height^2)))
> x %<>% filter(saffl == 'Y')
> x %<>% select(trt01a, age, sex, weight, bmi)
> x %<>% redecorate('
+ trt01a: [ Treatment, [ Placebo, TRT 10 mg, TRT 20 mg ]]
+ age:    [ Age, year ]
+ sex:    [ Sex, [ Female: F, Male: M ]]
+ weight: [ Body Weight, kg ]
+ bmi:    [ Index_body mass, kg/m^2 ]
+ ')
> x %<>% resolve
> x %<>% group_by(trt01a)
> 
> x %>% tablet %>% as_kable
Adding missing grouping variables: `Treatment`
Adding missing grouping variables: `Treatment`
Error:
! Must extract column with a single valid subscript.
✖ Subscript `token` has size 2 but must be size 1.
Backtrace:
     ▆
  1. ├─x %>% tablet %>% as_kable
  2. ├─tablet::as_kable(.)
  3. ├─tablet::tablet(.)
  4. └─tablet:::tablet.data.frame(.)
  5.   ├─tablet::groupwise(...)
  6.   └─tablet:::groupwise.data.frame(...)
  7.     ├─tablet::groupfull(x, fun = fun, fac = fac, num = num, ...)
  8.     └─tablet:::groupfull.data.frame(...)
  9.       ├─tablet::observations(x, ...)
 10.       └─tablet:::observations.data.frame(x, ...)
 11.         ├─tablet::categoricals(x, ...)
 12.         └─tablet:::categoricals.data.frame(x, ...)
 13.           ├─base::suppressWarnings(...)
 14.           │ └─base::withCallingHandlers(...)
 15.           ├─tidyr::gather(...)
 16.           └─yamlet:::gather.decorated(...)
 17.             ├─base::unique(x[[token]])
 18.             ├─x[[token]]
 19.             └─tibble:::`[[.tbl_df`(x, token)
 20.               └─tibble:::tbl_subset2(x, j = i, j_arg = substitute(i))
 21.                 └─tibble:::vectbl_as_col_location2(j, length(x), names(x), j_arg = j_arg)
 22.                   ├─tibble:::subclass_col_index_errors(...)
 23.                   │ └─base::withCallingHandlers(...)
 24.                   └─vctrs::vec_as_location2(j, n, names)
 25.                     └─vctrs:::result_get(...)
 26.                       └─rlang::cnd_signal(x$err)
Execution halted