Flexibly choose the right table output format for use with knitr.
Details
This function automatically selects the right function (texreg,
screenreg, htmlreg, or matrixreg) with the right set of
arguments for use with the knitr package, for example in RStudio. The
advantage of using this function with knitr is that the user does not
need to replace the texreg, htmlreg etc. function call in the
document when a different output format is selected. knitr can be used
directly for compiling .Rnw documents (integrating R code directly
into LaTeX), with the rmarkdown package (integrating R code into
Markdown and then calling Pandoc to create PDF via LaTeX, HTML, or Word
.docx), or with Quarto (integrating R code and Quarto markup into
Markdown and then calling Pandoc).
knitreg works with...
R HTML documents (
.Rhtmlextension)R Sweave documents (
.Rnwextension) for PDF output via LaTeX, rendered using...the knitr package
the Sweave package
R Markdown documents (
.Rmdextension), rendered as...HTML documents
PDF documents
Word documents
Powerpoint presentations
Presentations (
.Rpresextension, not.Rmd)
R Notebooks, including preview
Quarto documents (
.qmdextension), rendered as...HTML documents
PDF documents
Word documents
Other output formats offered by Pandoc.
If Markdown/Quarto and HTML rendering are selected, htmlreg arguments
doctype = FALSE and star.symbol = "*" are set to enable
compatibility with Markdown/Quarto. With R HTML documents (but not Markdown)
or .Rpres presentations, only doctype = FALSE is set.
For PDF/LaTeX documents, the texreg argument
use.packages = FALSE is set to suppress any package loading
instructions in the preamble. The user must load any packages manually in the
preamble of the document.
The knitr and rmarkdown packages must be installed for this function to work.
See also
Other texreg:
htmlreg(),
huxtablereg(),
matrixreg(),
plotreg(),
screenreg(),
texreg,
wordreg()
Examples
require("nlme")
model.1 <- lme(distance ~ age, data = Orthodont, random = ~ 1)
model.2 <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1)
knitreg(list(model.1, model.2), center = FALSE, caption = "", table = FALSE)
#>
#> ==============================================
#> Model 1 Model 2
#> ----------------------------------------------
#> (Intercept) 16.76 *** 17.71 ***
#> (0.80) (0.83)
#> age 0.66 *** 0.66 ***
#> (0.06) (0.06)
#> SexFemale -2.32 **
#> (0.76)
#> ----------------------------------------------
#> AIC 455.00 447.51
#> BIC 465.66 460.78
#> Log Likelihood -223.50 -218.76
#> Num. obs. 108 108
#> Num. groups: Subject 27 27
#> ==============================================
#> *** p < 0.001; ** p < 0.01; * p < 0.05