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

> ### Name: printCrudeAndAdjustedModel
> ### Title: Output crude and adjusted model data
> ### Aliases: printCrudeAndAdjustedModel rbind.printCrudeAndAdjusted
> ###   print.printCrudeAndAdjusted htmlTable.printCrudeAndAdjusted
> ###   [.printCrudeAndAdjusted cbind.printCrudeAndAdjusted
> ###   knit_print.printCrudeAndAdjusted latex.printCrudeAndAdjusted
> ### Keywords: internal
> 
> ### ** Examples
> 
> # simulated data to use
> set.seed(10)
> ds <- data.frame(
+   ftime = rexp(200),
+   fstatus = sample(0:1, 200, replace = TRUE),
+   Variable1 = runif(200),
+   Variable2 = runif(200),
+   Variable3 = runif(200),
+   Variable4 = factor(sample(LETTERS[1:4], size = 200, replace = TRUE))
+ )
> 
> library(rms)
Loading required package: Hmisc
Loading required package: lattice
Loading required package: survival
Loading required package: Formula
Loading required package: ggplot2

Attaching package: ‘Hmisc’

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

    format.pval, units

Loading required package: SparseM

Attaching package: ‘SparseM’

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

    backsolve

> dd <- datadist(ds)
> options(datadist = "dd")
> 
> fit <- cph(Surv(ftime, fstatus) ~ Variable1 + Variable3 + Variable2 + Variable4,
+   data = ds, x = TRUE, y = TRUE
+ )
> printCrudeAndAdjustedModel(fit, order = c("Variable[12]", "Variable3"))
<table class='gmisc_table' style='border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;' >
<thead>
<tr>
<th style='border-top: 2px solid grey;'></th>
<th colspan='2' style='font-weight: 900; border-bottom: 1px solid grey; border-top: 2px solid grey; text-align: center;'>Crude</th><th style='border-bottom: none; border-top: 2px solid grey;' colspan=1>&nbsp;</th>
<th colspan='2' style='font-weight: 900; border-bottom: 1px solid grey; border-top: 2px solid grey; text-align: center;'>Adjusted</th>
</tr>
<tr><th style='border-bottom: 1px solid grey; font-weight: 900; text-align: center;'>Variable</th>
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;'>HR</th>
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;'>2.5 % to 97.5 %</th> 
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;' colspan=1>&nbsp;</th>
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;'>HR</th>
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;'>2.5 % to 97.5 %</th>
</tr>
</thead>
<tbody>
<tr>
<td style='text-align: left;'>Variable1</td>
<td style='text-align: right;'>0.84</td>
<td style='text-align: center;'>0.44 to 1.58</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>0.95</td>
<td style='text-align: center;'>0.47 to 1.92</td>
</tr>
<tr>
<td style='text-align: left;'>Variable2</td>
<td style='text-align: right;'>1.07</td>
<td style='text-align: center;'>0.57 to 2.02</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>1.13</td>
<td style='text-align: center;'>0.59 to 2.17</td>
</tr>
<tr>
<td style='border-bottom: 2px solid grey; text-align: left;'>Variable3</td>
<td style='border-bottom: 2px solid grey; text-align: right;'>0.73</td>
<td style='border-bottom: 2px solid grey; text-align: center;'>0.38 to 1.39</td> 
<td style='border-bottom: 2px solid grey; text-align: center;' colspan=1>&nbsp;</td>
<td style='border-bottom: 2px solid grey; text-align: right;'>0.67</td>
<td style='border-bottom: 2px solid grey; text-align: center;'>0.34 to 1.29</td>
</tr>
</tbody>
</table>> printCrudeAndAdjustedModel(fit,
+   order = c("Variable3", "Variable4"),
+   add_references = TRUE,
+   desc_column = TRUE
+ )
<table class='gmisc_table' style='border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;' >
<thead>
<tr>
<th style='border-top: 2px solid grey;'></th>
<th colspan='2' style='font-weight: 900; border-top: 2px solid grey; text-align: center;'></th><th style='border-bottom: none; border-top: 2px solid grey;' colspan=1>&nbsp;</th>
<th colspan='2' style='font-weight: 900; border-bottom: 1px solid grey; border-top: 2px solid grey; text-align: center;'>Crude</th><th style='border-bottom: none; border-top: 2px solid grey;' colspan=1>&nbsp;</th>
<th colspan='2' style='font-weight: 900; border-bottom: 1px solid grey; border-top: 2px solid grey; text-align: center;'>Adjusted</th>
</tr>
<tr><th style='border-bottom: 1px solid grey; font-weight: 900; text-align: center;'>Variable</th>
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;'>Total</th>
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;'>Event</th> 
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;' colspan=1>&nbsp;</th>
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;'>HR</th>
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;'>2.5 % to 97.5 %</th> 
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;' colspan=1>&nbsp;</th>
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;'>HR</th>
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;'>2.5 % to 97.5 %</th>
</tr>
</thead>
<tbody>
<tr>
<td style='text-align: left;'>Variable3</td>
<td style='text-align: right;'>0.52 (&plusmn;0.30)</td>
<td style='text-align: right;'>0.47 (&plusmn;0.29)</td> 
<td style='text-align: right;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>0.73</td>
<td style='text-align: center;'>0.38 to 1.39</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>0.67</td>
<td style='text-align: center;'>0.34 to 1.29</td>
</tr> 
<tr><td colspan='9' style='font-weight: 900;'>Variable4</td></tr>
<tr>
<td style='text-align: left;'>&nbsp;&nbsp;A</td>
<td style='text-align: right;'>55</td>
<td style='text-align: right;'>25 (45.45%)</td> 
<td style='text-align: right;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>1.00</td>
<td style='text-align: center;'>ref</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>1.00</td>
<td style='text-align: center;'>ref</td>
</tr>
<tr>
<td style='text-align: left;'>&nbsp;&nbsp;B</td>
<td style='text-align: right;'>50</td>
<td style='text-align: right;'>26 (52.00%)</td> 
<td style='text-align: right;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>1.39</td>
<td style='text-align: center;'>0.80 to 2.40</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>1.40</td>
<td style='text-align: center;'>0.80 to 2.48</td>
</tr>
<tr>
<td style='text-align: left;'>&nbsp;&nbsp;C</td>
<td style='text-align: right;'>46</td>
<td style='text-align: right;'>30 (65.22%)</td> 
<td style='text-align: right;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>1.76</td>
<td style='text-align: center;'>1.03 to 3.00</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>1.81</td>
<td style='text-align: center;'>1.06 to 3.10</td>
</tr>
<tr>
<td style='border-bottom: 2px solid grey; text-align: left;'>&nbsp;&nbsp;D</td>
<td style='border-bottom: 2px solid grey; text-align: right;'>49</td>
<td style='border-bottom: 2px solid grey; text-align: right;'>30 (61.22%)</td> 
<td style='border-bottom: 2px solid grey; text-align: right;' colspan=1>&nbsp;</td>
<td style='border-bottom: 2px solid grey; text-align: right;'>1.58</td>
<td style='border-bottom: 2px solid grey; text-align: center;'>0.93 to 2.70</td> 
<td style='border-bottom: 2px solid grey; text-align: center;' colspan=1>&nbsp;</td>
<td style='border-bottom: 2px solid grey; text-align: right;'>1.58</td>
<td style='border-bottom: 2px solid grey; text-align: center;'>0.90 to 2.77</td>
</tr>
</tbody>
</table>> 
> # Now to a missing example
> n <- 500
> ds <- data.frame(
+   x1 = factor(sample(LETTERS[1:4], size = n, replace = TRUE)),
+   x2 = rnorm(n, mean = 3, 2),
+   x3 = factor(sample(letters[1:3], size = n, replace = TRUE))
+ )
> 
> ds$Missing_var1 <- factor(sample(letters[1:4], size = n, replace = TRUE))
> ds$Missing_var2 <- factor(sample(letters[1:4], size = n, replace = TRUE))
> ds$y <- rnorm(nrow(ds)) +
+   (as.numeric(ds$x1) - 1) * 1 +
+   (as.numeric(ds$Missing_var1) - 1) * 1 +
+   (as.numeric(ds$Missing_var2) - 1) * .5
> 
> # Create a messy missing variable
> non_random_missing <- sample(which(ds$Missing_var1 %in% c("b", "d")),
+   size = 150, replace = FALSE
+ )
> # Restrict the non-random number on the x2 variables
> non_random_missing <- non_random_missing[non_random_missing %in%
+   which(ds$x2 > mean(ds$x2) * 1.5) &
+   non_random_missing %in%
+     which(ds$x2 > mean(ds$y))]
> ds$Missing_var1[non_random_missing] <- NA
> 
> # Simple missing variable
> ds$Missing_var2[sample(1:nrow(ds), size = 50)] <- NA
> 
> # Setup the rms environment
> ddist <- datadist(ds)
> options(datadist = "ddist")
> 
> impute_formula <-
+   as.formula(paste(
+     "~",
+     paste(colnames(ds),
+       collapse = "+"
+     )
+   ))
> 
> imp_ds <- aregImpute(impute_formula, data = ds, n.impute = 10)
Iteration 1 
Iteration 2 
Iteration 3 
Iteration 4 
Iteration 5 
Iteration 6 
Iteration 7 
Iteration 8 
Iteration 9 
Iteration 10 
Iteration 11 
Iteration 12 
Iteration 13 
> 
> fmult <- fit.mult.impute(y ~ x1 + x2 + x3 +
+   Missing_var1 + Missing_var2,
+ fitter = ols, xtrans = imp_ds, data = ds
+ )

Variance Inflation Factors Due to Imputation:

     Intercept           x1=B           x1=C           x1=D             x2 
          1.03           1.07           1.05           1.07           1.14 
          x3=b           x3=c Missing_var1=b Missing_var1=c Missing_var1=d 
          1.09           1.02           1.06           1.09           1.02 
Missing_var2=b Missing_var2=c Missing_var2=d 
          1.06           1.19           1.06 

Rate of Missing Information:

     Intercept           x1=B           x1=C           x1=D             x2 
          0.03           0.07           0.05           0.06           0.12 
          x3=b           x3=c Missing_var1=b Missing_var1=c Missing_var1=d 
          0.09           0.02           0.06           0.08           0.02 
Missing_var2=b Missing_var2=c Missing_var2=d 
          0.05           0.16           0.06 

d.f. for t-distribution for Tests of Single Coefficients:

     Intercept           x1=B           x1=C           x1=D             x2 
       8249.89        2013.84        3971.93        2364.76         604.21 
          x3=b           x3=c Missing_var1=b Missing_var1=c Missing_var1=d 
       1227.72       20588.65        2743.89        1317.34       30736.60 
Missing_var2=b Missing_var2=c Missing_var2=d 
       3309.94         348.23        2477.44 

The following fit components were averaged over the 10 model fits:

  fitted.values stats linear.predictors 

> 
> printCrudeAndAdjustedModel(fmult,
+   impute_args = list(
+     variance.inflation = TRUE,
+     coef_change = list(
+       type = "diff",
+       digits = 3
+     )
+   )
+ )

Variance Inflation Factors Due to Imputation:

Intercept      x1=B      x1=C      x1=D 
        1         1         1         1 

Rate of Missing Information:

Intercept      x1=B      x1=C      x1=D 
        0         0         0         0 

d.f. for t-distribution for Tests of Single Coefficients:

   Intercept         x1=B         x1=C         x1=D 
2.266960e+26 1.485058e+28 1.748041e+27 4.408047e+26 

The following fit components were averaged over the 10 model fits:

  fitted.values stats linear.predictors 


Variance Inflation Factors Due to Imputation:

Intercept        x2 
        1         1 

Rate of Missing Information:

Intercept        x2 
        0         0 

d.f. for t-distribution for Tests of Single Coefficients:

   Intercept           x2 
4.243498e+25 3.634083e+37 

The following fit components were averaged over the 10 model fits:

  fitted.values stats linear.predictors 


Variance Inflation Factors Due to Imputation:

Intercept      x3=b      x3=c 
        1         1         1 

Rate of Missing Information:

Intercept      x3=b      x3=c 
        0         0         0 

d.f. for t-distribution for Tests of Single Coefficients:

   Intercept         x3=b         x3=c 
         Inf 2.437439e+31 2.226315e+34 

The following fit components were averaged over the 10 model fits:

  fitted.values stats linear.predictors 


Variance Inflation Factors Due to Imputation:

     Intercept Missing_var1=b Missing_var1=c Missing_var1=d 
          1.03           1.08           1.04           1.03 

Rate of Missing Information:

     Intercept Missing_var1=b Missing_var1=c Missing_var1=d 
          0.03           0.07           0.04           0.03 

d.f. for t-distribution for Tests of Single Coefficients:

     Intercept Missing_var1=b Missing_var1=c Missing_var1=d 
      13742.64        1782.15        6019.95       10207.13 

The following fit components were averaged over the 10 model fits:

  fitted.values stats linear.predictors 


Variance Inflation Factors Due to Imputation:

     Intercept Missing_var2=b Missing_var2=c Missing_var2=d 
          1.07           1.10           1.07           1.07 

Rate of Missing Information:

     Intercept Missing_var2=b Missing_var2=c Missing_var2=d 
          0.07           0.09           0.07           0.07 

d.f. for t-distribution for Tests of Single Coefficients:

     Intercept Missing_var2=b Missing_var2=c Missing_var2=d 
       1990.96        1025.28        1942.37        1960.29 

The following fit components were averaged over the 10 model fits:

  fitted.values stats linear.predictors 

<table class='gmisc_table' style='border-collapse: collapse; margin-top: 1em; margin-bottom: 1em;' >
<thead>
<tr>
<th style='border-top: 2px solid grey;'></th>
<th colspan='2' style='font-weight: 900; border-bottom: 1px solid grey; border-top: 2px solid grey; text-align: center;'>Crude</th><th style='border-bottom: none; border-top: 2px solid grey;' colspan=1>&nbsp;</th>
<th colspan='2' style='font-weight: 900; border-bottom: 1px solid grey; border-top: 2px solid grey; text-align: center;'>Adjusted</th><th style='border-bottom: none; border-top: 2px solid grey;' colspan=1>&nbsp;</th>
<th colspan='2' style='font-weight: 900; border-bottom: 1px solid grey; border-top: 2px solid grey; text-align: center;'>Imputation effect</th>
</tr>
<tr><th style='border-bottom: 1px solid grey; font-weight: 900; text-align: center;'>Variable</th>
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;'>Coef</th>
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;'>2.5 % to 97.5 %</th> 
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;' colspan=1>&nbsp;</th>
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;'>Coef</th>
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;'>2.5 % to 97.5 %</th> 
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;' colspan=1>&nbsp;</th>
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;'>Coefficient change</th>
<th style='font-weight: 900; border-bottom: 1px solid grey; text-align: center;'>Variance change</th>
</tr>
</thead>
<tbody> 
<tr><td colspan='9' style='font-weight: 900;'>x1</td></tr>
<tr>
<td style='text-align: left;'>&nbsp;&nbsp;B</td>
<td style='text-align: right;'>1.33</td>
<td style='text-align: center;'>0.96 to 1.70</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>1.06</td>
<td style='text-align: center;'>0.82 to 1.30</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>-0.023</td>
<td style='text-align: right;'>1.07</td>
</tr>
<tr>
<td style='text-align: left;'>&nbsp;&nbsp;C</td>
<td style='text-align: right;'>2.03</td>
<td style='text-align: center;'>1.66 to 2.41</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>1.95</td>
<td style='text-align: center;'>1.71 to 2.19</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>0.065</td>
<td style='text-align: right;'>1.05</td>
</tr>
<tr>
<td style='text-align: left;'>&nbsp;&nbsp;D</td>
<td style='text-align: right;'>3.13</td>
<td style='text-align: center;'>2.75 to 3.50</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>3.02</td>
<td style='text-align: center;'>2.78 to 3.26</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>0.042</td>
<td style='text-align: right;'>1.07</td>
</tr>
<tr>
<td style='text-align: left;'>x2</td>
<td style='text-align: right;'>0.00</td>
<td style='text-align: center;'>-0.08 to 0.08</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>0.00</td>
<td style='text-align: center;'>-0.04 to 0.04</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>-0.005</td>
<td style='text-align: right;'>1.14</td>
</tr> 
<tr><td colspan='9' style='font-weight: 900;'>x3</td></tr>
<tr>
<td style='text-align: left;'>&nbsp;&nbsp;b</td>
<td style='text-align: right;'>-0.22</td>
<td style='text-align: center;'>-0.63 to 0.20</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>-0.15</td>
<td style='text-align: center;'>-0.37 to 0.08</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>-0.082</td>
<td style='text-align: right;'>1.09</td>
</tr>
<tr>
<td style='text-align: left;'>&nbsp;&nbsp;c</td>
<td style='text-align: right;'>-0.06</td>
<td style='text-align: center;'>-0.46 to 0.35</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>-0.08</td>
<td style='text-align: center;'>-0.29 to 0.13</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>-0.025</td>
<td style='text-align: right;'>1.02</td>
</tr> 
<tr><td colspan='9' style='font-weight: 900;'>Missing_var1</td></tr>
<tr>
<td style='text-align: left;'>&nbsp;&nbsp;b</td>
<td style='text-align: right;'>1.11</td>
<td style='text-align: center;'>0.71 to 1.51</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>1.10</td>
<td style='text-align: center;'>0.86 to 1.35</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>0.023</td>
<td style='text-align: right;'>1.06</td>
</tr>
<tr>
<td style='text-align: left;'>&nbsp;&nbsp;c</td>
<td style='text-align: right;'>2.22</td>
<td style='text-align: center;'>1.83 to 2.61</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>2.17</td>
<td style='text-align: center;'>1.92 to 2.41</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>-0.031</td>
<td style='text-align: right;'>1.09</td>
</tr>
<tr>
<td style='text-align: left;'>&nbsp;&nbsp;d</td>
<td style='text-align: right;'>2.92</td>
<td style='text-align: center;'>2.52 to 3.33</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>2.91</td>
<td style='text-align: center;'>2.67 to 3.16</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>-0.065</td>
<td style='text-align: right;'>1.02</td>
</tr> 
<tr><td colspan='9' style='font-weight: 900;'>Missing_var2</td></tr>
<tr>
<td style='text-align: left;'>&nbsp;&nbsp;b</td>
<td style='text-align: right;'>0.31</td>
<td style='text-align: center;'>-0.17 to 0.78</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>0.45</td>
<td style='text-align: center;'>0.20 to 0.69</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>-0.013</td>
<td style='text-align: right;'>1.06</td>
</tr>
<tr>
<td style='text-align: left;'>&nbsp;&nbsp;c</td>
<td style='text-align: right;'>0.93</td>
<td style='text-align: center;'>0.46 to 1.40</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>0.82</td>
<td style='text-align: center;'>0.57 to 1.08</td> 
<td style='text-align: center;' colspan=1>&nbsp;</td>
<td style='text-align: right;'>-0.010</td>
<td style='text-align: right;'>1.19</td>
</tr>
<tr>
<td style='border-bottom: 2px solid grey; text-align: left;'>&nbsp;&nbsp;d</td>
<td style='border-bottom: 2px solid grey; text-align: right;'>1.25</td>
<td style='border-bottom: 2px solid grey; text-align: center;'>0.77 to 1.72</td> 
<td style='border-bottom: 2px solid grey; text-align: center;' colspan=1>&nbsp;</td>
<td style='border-bottom: 2px solid grey; text-align: right;'>1.48</td>
<td style='border-bottom: 2px solid grey; text-align: center;'>1.24 to 1.73</td> 
<td style='border-bottom: 2px solid grey; text-align: center;' colspan=1>&nbsp;</td>
<td style='border-bottom: 2px solid grey; text-align: right;'>0.006</td>
<td style='border-bottom: 2px solid grey; text-align: right;'>1.06</td>
</tr>
</tbody>
</table>> 
> 
> # Use some labels and style to prettify the output
> # fro the mtcars dataset
> data("mtcars")
> 
> label(mtcars$mpg) <- "Gas"
> units(mtcars$mpg) <- "Miles/(US) gallon"
> 
> label(mtcars$wt) <- "Weight"
> units(mtcars$wt) <- "10^3 kg" # not sure the unit is correct
> 
> mtcars$am <- factor(mtcars$am, levels = 0:1, labels = c("Automatic", "Manual"))
> label(mtcars$am) <- "Transmission"
> 
> mtcars$gear <- factor(mtcars$gear)
> label(mtcars$gear) <- "Gears"
> 
> # Make up some data for making it slightly more interesting
> mtcars$col <- factor(sample(c("red", "black", "silver"), size = NROW(mtcars), replace = TRUE))
> label(mtcars$col) <- "Car color"
> 
> require(splines)
Loading required package: splines
> fit_mtcar <- lm(mpg ~ wt + gear + col, data = mtcars)
> printCrudeAndAdjustedModel(fit_mtcar,
+   add_references = TRUE,
+   ctable = TRUE,
+   desc_column = TRUE,
+   digits = 1,
+   desc_args = caDescribeOpts(
+     digits = 1,
+     colnames = c("Avg.")
+   )) %>% 
+   htmlTable::addHtmlTableStyle(css.rgroup = "",
+                                css.header = "font-weight: normal")
Error in printCrudeAndAdjustedModel(fit_mtcar, add_references = TRUE,  : 
  could not find function "%>%"
Execution halted