rmd2html {accessr} | R Documentation |
Converts R markdown code to html documents
Description
Creates accessible html documents using R markdown's
html_document
argument to
render
. Zip archives of the html files may be
created.
Usage
rmd2html(
x,
zip = if (length(x) == 1 & !add) FALSE else TRUE,
pdf = FALSE,
pdf_args = list(),
zip_pdf = zip,
add = FALSE,
quiet = TRUE,
rm_html = FALSE,
rm_pdf = FALSE,
...
)
Arguments
x |
A character vector containing the names (no extension) of
the |
zip |
A logical scalar or character vector indicating whether html
files should be put into a zip archive. If |
pdf |
A logical scalar. If |
pdf_args |
A list of arguments passed to
|
zip_pdf |
As |
add |
A logical scalar that determines what happens if an output
zip file already exists. If |
quiet |
Argument of the same name passed to
|
rm_html |
A logical scalar. If |
rm_pdf |
A logical scalar. If |
... |
Additional arguments passed to
|
Details
Information such as title
, author
, lang
etc in
the YAML header in the Rmd file are used but output
is ignored.
The simplest setup is to have the .Rmd
files in the current
working directory, in which case rmd2html()
will create HTML documents
from all these Rmd files, the .Rmd
files may be in different
directories.
The render
function, with the argument
output_file =
html_document
creates the html files.
Value
In addition to creating the html files, and perhaps zip files, a list containing the following (character vector) components is returned invisibly:
files |
(absolute) paths and file names of the files added to a zip file. |
zips |
(relative) paths and names of all the zip files. |
See Also
rmd2many
, rmd2word
,
rmd2ioslides
, rmd2slidy
for other output
formats.
The accessr package page on Github.
Examples
# Create an HTML document from example.Rmd
got_hux <- requireNamespace("huxtable", quietly = TRUE)
got_flex <- requireNamespace("flextable", quietly = TRUE)
got_pandoc <- rmarkdown::pandoc_available("1.14")
got_all <- got_hux && got_flex && got_pandoc
# This example needs packages huxtable and flextable
if (got_all) {
ex_file <- system.file(package = "accessr", "examples", "example.Rmd")
file.copy(ex_file, tdir <- tempdir(check = TRUE), overwrite = TRUE)
ex_file <- list.files(tdir, pattern = "example.Rmd", full.names = TRUE)
ex_file <- sub(".Rmd", "", ex_file)
rmd2html(ex_file)
}