Skip to contents

These functions are wrapped versions of their analogues in the pander package. They imbue the original implementations with logger functionality.

Usage

pander(x = NULL, ...)

pander_return(...)

Arguments

x

an R object

...

optional parameters passed to special methods and/or raw pandoc.* functions

Value

By default this function outputs (see: cat) the result. If you would want to catch the result instead, then call the function ending in .return.

Note

This function can be called by pander and pandoc too.

References

See also

pander

Examples

## Vectors
pander(1:10)
#> _1_, _2_, _3_, _4_, _5_, _6_, _7_, _8_, _9_ and _10_
pander(letters)
#> _a_, _b_, _c_, _d_, _e_, _f_, _g_, _h_, _i_, _j_, _k_, _l_, _m_, _n_, _o_, _p_, _q_, _r_, _s_, _t_, _u_, _v_, _w_, _x_, _y_ and _z_
pander(mtcars$am)
#> _1_, _1_, _1_, _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_, _1_, _1_, _1_, _0_, _0_, _0_, _0_, _0_, _1_, _1_, _1_, _1_, _1_, _1_ and _1_
pander(factor(mtcars$am))
#> _2_, _2_, _2_, _1_, _1_, _1_, _1_, _1_, _1_, _1_, _1_, _1_, _1_, _1_, _1_, _1_, _1_, _2_, _2_, _2_, _1_, _1_, _1_, _1_, _1_, _2_, _2_, _2_, _2_, _2_, _2_ and _2_

## Lists
pander(list(1, 2, 3, c(1, 2)))
#> 
#> 
#>   * _1_
#>   * _2_
#>   * _3_
#>   * _1_ and _2_
#> 
#> <!-- end of list -->
#> 
#> 
pander(list(a = 1, b = 2, c = table(mtcars$am)))
#> 
#> 
#>   * **a**: _1_
#>   * **b**: _2_
#>   * **c**:
#> 
#>     ---------
#>      0    1
#>     ---- ----
#>      19   13
#>     ---------
#> 
#> 
#> <!-- end of list -->
#> 
#> 
pander(list(1, 2, 3, list(1, 2)))
#> 
#> 
#>   * _1_
#>   * _2_
#>   * _3_
#>   *
#> 
#>       * _1_
#>       * _2_
#> 
#> 
#> <!-- end of list -->
#> 
#> 
pander(list(a = 1, 2, 3, list(1, 2)))
#> 
#> 
#>   * **a**: _1_
#>   * _2_
#>   * _3_
#>   *
#> 
#>       * _1_
#>       * _2_
#> 
#> 
#> <!-- end of list -->
#> 
#> 
pander(list('FOO', letters[1:3], list(1:5), table(mtcars$gear), list('FOOBAR', list('a', 'b'))))
#> 
#> 
#>   * FOO
#>   * _a_, _b_ and _c_
#>   *
#> 
#>       * _1_, _2_, _3_, _4_ and _5_
#> 
#>   *
#> 
#>     -------------
#>      3    4    5
#>     ---- ---- ---
#>      15   12   5
#>     -------------
#> 
#>   *
#> 
#>       * FOOBAR
#>       *
#> 
#>           * a
#>           * b
#> 
#> 
#> 
#> <!-- end of list -->
#> 
#> 
pander(list(a = 1, b = 2, c = table(mtcars$am), x = list(myname = 1, 2), 56))
#> 
#> 
#>   * **a**: _1_
#>   * **b**: _2_
#>   * **c**:
#> 
#>     ---------
#>      0    1
#>     ---- ----
#>      19   13
#>     ---------
#> 
#>   * **x**:
#> 
#>       * **myname**: _1_
#>       * _2_
#> 
#>   * _56_
#> 
#> <!-- end of list -->
#> 
#> 
pander(unclass(chisq.test(table(mtcars$am, mtcars$gear))))
#> Warning: Chi-squared approximation may be incorrect
#> 
#> 
#>   * **statistic**:
#> 
#>     -----------
#>      X-squared
#>     -----------
#>        20.94
#>     -----------
#> 
#>   * **parameter**:
#> 
#>     ----
#>      df
#>     ----
#>      2
#>     ----
#> 
#>   * **p.value**: _2.831e-05_
#>   * **method**: Pearson's Chi-squared test
#>   * **data.name**: table(mtcars$am, mtcars$gear)
#>   * **observed**:
#> 
#>     ---------------------
#>      &nbsp;   3    4   5
#>     -------- ---- --- ---
#>      **0**    15   4   0
#> 
#>      **1**    0    8   5
#>     ---------------------
#> 
#>   * **expected**:
#> 
#>     --------------------------------
#>      &nbsp;     3       4       5
#>     -------- ------- ------- -------
#>      **0**    8.906   7.125   2.969
#> 
#>      **1**    6.094   4.875   2.031
#>     --------------------------------
#> 
#>   * **residuals**:
#> 
#>     -----------------------------------
#>      &nbsp;     3        4        5
#>     -------- -------- -------- --------
#>      **0**    2.042    -1.171   -1.723
#> 
#>      **1**    -2.469   1.415    2.083
#>     -----------------------------------
#> 
#>   * **stdres**:
#> 
#>     -----------------------------------
#>      &nbsp;     3        4        5
#>     -------- -------- -------- --------
#>      **0**    4.395    -2.323   -2.943
#> 
#>      **1**    -4.395   2.323    2.943
#>     -----------------------------------
#> 
#> 
#> <!-- end of list -->
#> 
#> 

## Arrays
pander(mtcars)
#> 
#> --------------------------------------------------------------------------------
#>          &nbsp;            mpg    cyl   disp    hp    drat    wt     qsec    vs 
#> ------------------------- ------ ----- ------- ----- ------ ------- ------- ----
#>       **Mazda RX4**         21     6     160    110   3.9    2.62    16.46   0  
#> 
#>     **Mazda RX4 Wag**       21     6     160    110   3.9    2.875   17.02   0  
#> 
#>      **Datsun 710**        22.8    4     108    93    3.85   2.32    18.61   1  
#> 
#>    **Hornet 4 Drive**      21.4    6     258    110   3.08   3.215   19.44   1  
#> 
#>   **Hornet Sportabout**    18.7    8     360    175   3.15   3.44    17.02   0  
#> 
#>        **Valiant**         18.1    6     225    105   2.76   3.46    20.22   1  
#> 
#>      **Duster 360**        14.3    8     360    245   3.21   3.57    15.84   0  
#> 
#>       **Merc 240D**        24.4    4    146.7   62    3.69   3.19     20     1  
#> 
#>       **Merc 230**         22.8    4    140.8   95    3.92   3.15    22.9    1  
#> 
#>       **Merc 280**         19.2    6    167.6   123   3.92   3.44    18.3    1  
#> 
#>       **Merc 280C**        17.8    6    167.6   123   3.92   3.44    18.9    1  
#> 
#>      **Merc 450SE**        16.4    8    275.8   180   3.07   4.07    17.4    0  
#> 
#>      **Merc 450SL**        17.3    8    275.8   180   3.07   3.73    17.6    0  
#> 
#>      **Merc 450SLC**       15.2    8    275.8   180   3.07   3.78     18     0  
#> 
#>  **Cadillac Fleetwood**    10.4    8     472    205   2.93   5.25    17.98   0  
#> 
#>  **Lincoln Continental**   10.4    8     460    215    3     5.424   17.82   0  
#> 
#>   **Chrysler Imperial**    14.7    8     440    230   3.23   5.345   17.42   0  
#> 
#>       **Fiat 128**         32.4    4    78.7    66    4.08    2.2    19.47   1  
#> 
#>      **Honda Civic**       30.4    4    75.7    52    4.93   1.615   18.52   1  
#> 
#>    **Toyota Corolla**      33.9    4    71.1    65    4.22   1.835   19.9    1  
#> 
#>     **Toyota Corona**      21.5    4    120.1   97    3.7    2.465   20.01   1  
#> 
#>   **Dodge Challenger**     15.5    8     318    150   2.76   3.52    16.87   0  
#> 
#>      **AMC Javelin**       15.2    8     304    150   3.15   3.435   17.3    0  
#> 
#>      **Camaro Z28**        13.3    8     350    245   3.73   3.84    15.41   0  
#> 
#>   **Pontiac Firebird**     19.2    8     400    175   3.08   3.845   17.05   0  
#> 
#>       **Fiat X1-9**        27.3    4     79     66    4.08   1.935   18.9    1  
#> 
#>     **Porsche 914-2**       26     4    120.3   91    4.43   2.14    16.7    0  
#> 
#>     **Lotus Europa**       30.4    4    95.1    113   3.77   1.513   16.9    1  
#> 
#>    **Ford Pantera L**      15.8    8     351    264   4.22   3.17    14.5    0  
#> 
#>     **Ferrari Dino**       19.7    6     145    175   3.62   2.77    15.5    0  
#> 
#>     **Maserati Bora**       15     8     301    335   3.54   3.57    14.6    0  
#> 
#>      **Volvo 142E**        21.4    4     121    109   4.11   2.78    18.6    1  
#> --------------------------------------------------------------------------------
#> 
#> Table: Table continues below
#> 
#>  
#> --------------------------------------------
#>          &nbsp;            am   gear   carb 
#> ------------------------- ---- ------ ------
#>       **Mazda RX4**        1     4      4   
#> 
#>     **Mazda RX4 Wag**      1     4      4   
#> 
#>      **Datsun 710**        1     4      1   
#> 
#>    **Hornet 4 Drive**      0     3      1   
#> 
#>   **Hornet Sportabout**    0     3      2   
#> 
#>        **Valiant**         0     3      1   
#> 
#>      **Duster 360**        0     3      4   
#> 
#>       **Merc 240D**        0     4      2   
#> 
#>       **Merc 230**         0     4      2   
#> 
#>       **Merc 280**         0     4      4   
#> 
#>       **Merc 280C**        0     4      4   
#> 
#>      **Merc 450SE**        0     3      3   
#> 
#>      **Merc 450SL**        0     3      3   
#> 
#>      **Merc 450SLC**       0     3      3   
#> 
#>  **Cadillac Fleetwood**    0     3      4   
#> 
#>  **Lincoln Continental**   0     3      4   
#> 
#>   **Chrysler Imperial**    0     3      4   
#> 
#>       **Fiat 128**         1     4      1   
#> 
#>      **Honda Civic**       1     4      2   
#> 
#>    **Toyota Corolla**      1     4      1   
#> 
#>     **Toyota Corona**      0     3      1   
#> 
#>   **Dodge Challenger**     0     3      2   
#> 
#>      **AMC Javelin**       0     3      2   
#> 
#>      **Camaro Z28**        0     3      4   
#> 
#>   **Pontiac Firebird**     0     3      2   
#> 
#>       **Fiat X1-9**        1     4      1   
#> 
#>     **Porsche 914-2**      1     5      2   
#> 
#>     **Lotus Europa**       1     5      2   
#> 
#>    **Ford Pantera L**      1     5      4   
#> 
#>     **Ferrari Dino**       1     5      6   
#> 
#>     **Maserati Bora**      1     5      8   
#> 
#>      **Volvo 142E**        1     4      2   
#> --------------------------------------------
#> 
pander(table(mtcars$am))
#> 
#> ---------
#>  0    1  
#> ---- ----
#>  19   13 
#> ---------
#> 
pander(table(mtcars$am, mtcars$gear))
#> 
#> ---------------------
#>  &nbsp;   3    4   5 
#> -------- ---- --- ---
#>  **0**    15   4   0 
#> 
#>  **1**    0    8   5 
#> ---------------------
#> 

## Tests
pander(ks.test(runif(50), runif(50)))
#> 
#> ---------------------------------------------------
#>  Test statistic   P value   Alternative hypothesis 
#> ---------------- --------- ------------------------
#>       0.22        0.1786          two-sided        
#> ---------------------------------------------------
#> 
#> Table: Exact two-sample Kolmogorov-Smirnov test: `runif(50)` and `runif(50)`
#> 
pander(chisq.test(table(mtcars$am, mtcars$gear)))
#> Warning: Chi-squared approximation may be incorrect
#> 
#> ---------------------------------------
#>  Test statistic   df       P value     
#> ---------------- ---- -----------------
#>      20.94        2    2.831e-05 * * * 
#> ---------------------------------------
#> 
#> Table: Pearson's Chi-squared test: `table(mtcars$am, mtcars$gear)`
#> 
pander(t.test(extra ~ group, data = sleep))
#> 
#> -----------------------------------------------------------------------------
#>  Test statistic    df     P value   Alternative hypothesis   mean in group 1 
#> ---------------- ------- --------- ------------------------ -----------------
#>      -1.861       17.78   0.07939         two.sided               0.75       
#> -----------------------------------------------------------------------------
#> 
#> Table: Welch Two Sample t-test: `extra` by `group` (continued below)
#> 
#>  
#> -----------------
#>  mean in group 2 
#> -----------------
#>       2.33       
#> -----------------
#> 

## Models
ml <- with(lm(mpg ~ hp + wt), data = mtcars)
pander(ml)
#> 
#> ---------------------------------------------------------------
#>      &nbsp;        Estimate   Std. Error   t value   Pr(>|t|)  
#> ----------------- ---------- ------------ --------- -----------
#>  **(Intercept)**    37.23       1.599       23.28    2.565e-20 
#> 
#>      **hp**        -0.03177    0.00903     -3.519    0.001451  
#> 
#>      **wt**         -3.878      0.6327     -6.129    1.12e-06  
#> ---------------------------------------------------------------
#> 
#> Table: Fitting linear model: mpg ~ hp + wt
#> 
pander(anova(ml))
#> 
#> -------------------------------------------------------------
#>     &nbsp;       Df   Sum Sq   Mean Sq   F value    Pr(>F)   
#> --------------- ---- -------- --------- --------- -----------
#>     **hp**       1    678.4     678.4     100.9    5.987e-11 
#> 
#>     **wt**       1    252.6     252.6     37.56    1.12e-06  
#> 
#>  **Residuals**   29    195      6.726      NA         NA     
#> -------------------------------------------------------------
#> 
#> Table: Analysis of Variance Table
#> 
pander(aov(ml))
#> 
#> -------------------------------------------------------------
#>     &nbsp;       Df   Sum Sq   Mean Sq   F value    Pr(>F)   
#> --------------- ---- -------- --------- --------- -----------
#>     **hp**       1    678.4     678.4     100.9    5.987e-11 
#> 
#>     **wt**       1    252.6     252.6     37.56    1.12e-06  
#> 
#>  **Residuals**   29    195      6.726      NA         NA     
#> -------------------------------------------------------------
#> 
#> Table: Analysis of Variance Model
#> 
## Dobson (1990) Page 93: Randomized Controlled Trial (examples from: ?glm)
counts <- c(18, 17, 15, 20, 10, 20, 25, 13, 12)
outcome <- gl(3, 1, 9)
treatment <- gl(3, 3)
m <- glm(counts ~ outcome + treatment, family = poisson())
pander(m)
#> 
#> ------------------------------------------------------------------
#>      &nbsp;        Estimate    Std. Error    z value    Pr(>|z|)  
#> ----------------- ----------- ------------ ----------- -----------
#>  **(Intercept)**     3.045       0.1709       17.81     5.427e-71 
#> 
#>   **outcome2**      -0.4543      0.2022      -2.247      0.02465  
#> 
#>   **outcome3**      -0.293       0.1927       -1.52      0.1285   
#> 
#>  **treatment2**    1.218e-15      0.2       6.088e-15       1     
#> 
#>  **treatment3**    8.438e-16      0.2       4.219e-15       1     
#> ------------------------------------------------------------------
#> 
#> Table: Fitting generalized (poisson/log) linear model: counts ~ outcome + treatment
#> 
pander(anova(m))
#> 
#> --------------------------------------------------------------------
#>     &nbsp;       Df   Deviance    Resid. Df   Resid. Dev   Pr(>Chi) 
#> --------------- ---- ----------- ----------- ------------ ----------
#>    **NULL**      NA      NA           8         10.58         NA    
#> 
#>   **outcome**    2      5.452         6         5.129      0.06547  
#> 
#>  **treatment**   2    6.217e-15       4         5.129         1     
#> --------------------------------------------------------------------
#> 
#> Table: Analysis of Deviance Table
#> 
pander(aov(m))
#> 
#> ----------------------------------------------------------------
#>     &nbsp;       Df    Sum Sq     Mean Sq     F value    Pr(>F) 
#> --------------- ---- ----------- ---------- ----------- --------
#>   **outcome**    2      92.67      46.33       2.224     0.2242 
#> 
#>  **treatment**   2    9.861e-31   4.93e-31   2.367e-32     1    
#> 
#>  **Residuals**   4      83.33      20.83        NA         NA   
#> ----------------------------------------------------------------
#> 
#> Table: Analysis of Variance Model
#> 
## overwriting labels
pander(lm(Sepal.Width ~ Species, data = iris), covariate.labels = c('Versicolor', 'Virginica'))
#> 
#> ---------------------------------------------------------------------
#>         &nbsp;          Estimate   Std. Error   t value    Pr(>|t|)  
#> ---------------------- ---------- ------------ --------- ------------
#>     **Versicolor**       3.428      0.04804      71.36    5.708e-116 
#> 
#>     **Virginica**        -0.658     0.06794     -9.685    1.832e-17  
#> 
#>  **Speciesvirginica**    -0.454     0.06794     -6.683    4.539e-10  
#> ---------------------------------------------------------------------
#> 
#> Table: Fitting linear model: Sepal.Width ~ Species
#> 

## Prcomp
pander(prcomp(USArrests))
#> 
#> ---------------------------------------------------------
#>     &nbsp;        PC1       PC2        PC3        PC4    
#> -------------- --------- ---------- ---------- ----------
#>   **Murder**    0.0417    -0.04482   0.07989    -0.9949  
#> 
#>  **Assault**    0.9952    -0.05876   -0.06757   0.03894  
#> 
#>  **UrbanPop**   0.04634    0.9769    -0.2005    -0.05817 
#> 
#>    **Rape**     0.07516    0.2007     0.9741    0.07233  
#> ---------------------------------------------------------
#> 
#> Table: Principal Components Analysis
#> 

## Others
pander(density(runif(10)))
#> 
#> --------------------------------------------
#>    &nbsp;      Coordinates   Density values 
#> ------------- ------------- ----------------
#>   **Min.**       -0.133         0.003805    
#> 
#>  **1st Qu.**      0.197          0.1455     
#> 
#>  **Median**       0.527          0.7132     
#> 
#>   **Mean**        0.527          0.7558     
#> 
#>  **3rd Qu.**      0.857          1.428      
#> 
#>   **Max.**        1.187          1.492      
#> --------------------------------------------
#> 
#> Table: Kernel density of *runif(10)* (bandwidth: 0.1171332)
#> 
pander(density(mtcars$hp))
#> 
#> --------------------------------------------
#>    &nbsp;      Coordinates   Density values 
#> ------------- ------------- ----------------
#>   **Min.**       -32.12        4.956e-06    
#> 
#>  **1st Qu.**      80.69        0.0004066    
#> 
#>  **Median**       193.5         0.001663    
#> 
#>   **Mean**        193.5         0.002212    
#> 
#>  **3rd Qu.**      306.3         0.004087    
#> 
#>   **Max.**        419.1         0.006048    
#> --------------------------------------------
#> 
#> Table: Kernel density of *mtcars$hp* (bandwidth: 28.04104)
#> 

## default method
x <- chisq.test(table(mtcars$am, mtcars$gear))
#> Warning: Chi-squared approximation may be incorrect
class(x) <- 'I heave never heard of!'
pander(x)
#> Warning: No pander.method for "I heave never heard of!", reverting to default.
#> 
#> 
#>   * **statistic**:
#> 
#>     -----------
#>      X-squared
#>     -----------
#>        20.94
#>     -----------
#> 
#>   * **parameter**:
#> 
#>     ----
#>      df
#>     ----
#>      2
#>     ----
#> 
#>   * **p.value**: _2.831e-05_
#>   * **method**: Pearson's Chi-squared test
#>   * **data.name**: table(mtcars$am, mtcars$gear)
#>   * **observed**:
#> 
#>     ---------------------
#>      &nbsp;   3    4   5
#>     -------- ---- --- ---
#>      **0**    15   4   0
#> 
#>      **1**    0    8   5
#>     ---------------------
#> 
#>   * **expected**:
#> 
#>     --------------------------------
#>      &nbsp;     3       4       5
#>     -------- ------- ------- -------
#>      **0**    8.906   7.125   2.969
#> 
#>      **1**    6.094   4.875   2.031
#>     --------------------------------
#> 
#>   * **residuals**:
#> 
#>     -----------------------------------
#>      &nbsp;     3        4        5
#>     -------- -------- -------- --------
#>      **0**    2.042    -1.171   -1.723
#> 
#>      **1**    -2.469   1.415    2.083
#>     -----------------------------------
#> 
#>   * **stdres**:
#> 
#>     -----------------------------------
#>      &nbsp;     3        4        5
#>     -------- -------- -------- --------
#>      **0**    4.395    -2.323   -2.943
#> 
#>      **1**    -4.395   2.323    2.943
#>     -----------------------------------
#> 
#> 
#> <!-- end of list -->
#> 
#>