From a single R markdown file create HTML slides, PDF slides, Word and PDF documents.
Arguments
- x
A character vector containing the names (no extension) of the
.Rmdfiles to convert if they are in the current working directory, or paths to the files, either absolute or relative to the current working directory, e.g.,DIRECTORY/file1. The output files are created in the same directory as their respective.Rmdfile.- outputs
A character vector. Specifies the output formats required. A subset of
c("word", "ioslides", "slidy", "html"). If more than one of"ioslides","slidy"and"html"are present then only one of these is used with the order of preference"ioslides","slidy"then"html".- slide_level
Passed to
rmd2ioslidesvia.... The defaultslide_level = 1means that a level one header # create a new non-segue slide for an ioslides presentation.- css
The argument
csspassed toioslides_presentationorslidy_presentation. Ifcss = "black"thenaccessr's css fileblack.cssis used, which results in black text being used in the slides.cssis not used ifoutputs = html.- add18
A logical scalar. If
TRUEthen we also create Word documents with 18pt text.A logical scalar. If
TRUEthen we usechrome_printto print PDF versions of HTML files produced using the output"ioslides"or"slidy". and/orOfficeToPDF.exeto create PDF files from any Word documents that are produced.- highlight
A named list, with names a subset of
c("word", "ioslides", "slidy"), providing the respective syntax highlighting styles passed to Pandoc for the output formats. Any syntax highlighting provided incsswill take precedence.highlightis not used ifoutputs = html.- params
A list of named parameters to pass as the argument
paramstorender. In the example below, the fileexample.Rmdhas a parameterhide. Ifhide = TRUEthen parts of the output are hidden using theknitrchunk optionsechoandeval.- zip
A logical scalar or character vector indicating whether PDF files should be put into a zip archive. If
zip = FALSEthen no zip archive is created. Otherwise, an archive is created in each unique directory involved inx. Ifzip = TRUEthen any archive created is named after the first filename inxfrom the relevant directory. Ifzipis a character vector of zip file names (no extension) then these names are used to name the zip archives. The names are recycled to the length of the number of unique directories if necessary.- ...
Additional arguments to be passed to
rmd2ioslides,rmd2slidy,rmd2wordorrmd2html.
Value
A list containing the following components:
- files
names of all the files created.
- zips
names of all zip files created (if
zip = TRUE).
Details
The default setting creates, for each valid filename in x, the
following files
filename.html: lecture slides inioslidesformat.filename_slides.pdf: a PDF document containing the content infilename.html.filename.pdf: a PDF document created from a Word document produced byrmd2word.filename.docx: a Word document.filename18pt.docx: a Word document. Ifadd18 = TRUEthen a template Word document with 18pt bold text is used.filename.zip: a zip file containing all the files produced.
See also
install_otp to install
OfficeToPDF.
Examples
# Create documents 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
# We pass pdf = FALSE because OfficeToPDF is needed to convert Word to PDF
# and this is only relevant on a Windows Operating System.
#
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)
rmd2many(ex_file, params = list(hide = TRUE), pdf = FALSE, zip = TRUE)
}
#> $files
#> [1] "C:/Users/Paul/AppData/Local/Temp/RtmpAbmoQY/example.html"
#> [2] "C:/Users/Paul/AppData/Local/Temp/RtmpAbmoQY/example18pt.docx"
#> [3] "C:/Users/Paul/AppData/Local/Temp/RtmpAbmoQY/example.docx"
#>
#> $zips
#> [1] "C:/Users/Paul/AppData/Local/Temp/RtmpAbmoQY/example.zip"
#>