### shiny_prerendered_server_start_code Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Get the server startup code for a shiny_prerendered server instance. ```APIDOC ## shiny_prerendered_server_start_code ### Description Get the server startup code for a shiny_prerendered server instance. ### Usage ```R shiny_prerendered_server_start_code(server_envir) ``` ### Arguments - `server_envir` (environment) - Shiny server environment to get code for. ``` -------------------------------- ### Get Server Startup Code Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Retrieves the server startup code for a Shiny prerendered server instance. Requires the Shiny server environment as input. ```R shiny_prerendered_server_start_code(server_envir) ``` -------------------------------- ### Check Pandoc Availability and Version Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Determine if Pandoc is installed and accessible on the system, optionally checking for a minimum version. Retrieves the specific version of Pandoc found. ```R library(rmarkdown) if (pandoc_available()) cat("pandoc", as.character(pandoc_version()), "is available!\n") if (pandoc_available("1.12.3")) cat("required version of pandoc is available!\n") ``` -------------------------------- ### Run Shiny Document Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Runs a Shiny document by starting an associated Shiny server. Configure the server using `shiny_args` and enable auto-reloading by setting `auto_reload` to TRUE. The server renders the document on demand or when changes are detected. ```R rmarkdown::run() ``` ```R rmarkdown::run("shiny_doc.Rmd", shiny_args = list(port = 8241)) ``` -------------------------------- ### Run a Shiny document Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Start a Shiny server for the given document, and render it for display. This function is used to run R Markdown documents as interactive Shiny applications. ```APIDOC ## run ### Description Start a Shiny server for the given document, and render it for display. ### Usage ```R run( file = "index.Rmd", dir = dirname(file), default_file = NULL, auto_reload = TRUE, shiny_args = NULL, render_args = NULL ) ``` ### Arguments - `file` (character) - Path to the R Markdown document to launch in a web browser. Defaults to `index.Rmd` in the current working directory, but may be `NULL` to skip launching a browser. - `dir` (character) - The directory from which to to read input documents. Defaults to the parent directory of `file`. - `default_file` (character) - The file to serve at the Shiny server's root URL. If `NULL` (the default), a sensible default is chosen (see Details) - `auto_reload` (logical) - If `TRUE` (the default), automatically reload the Shiny application when the file currently being viewed is changed on disk. - `shiny_args` (list) - Additional arguments to `runApp`. - `render_args` (list) - Additional arguments to `render`. ``` -------------------------------- ### Beamer Presentation Format Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html R Markdown output format for creating Beamer presentations. Requires LaTeX installation. ```APIDOC ## Beamer Presentation ### Description Output format for creating Beamer PDF presentations from R Markdown. ### Usage ```R beamer_presentation(..., toc = FALSE, toc_depth = 2, number_sections = FALSE, fig_width = 6.5, fig_height = 4.5, fig_caption = TRUE, md_extensions = NULL, pandoc_args = NULL, keep_tex = FALSE) ``` ### Details See the online documentation for additional details on using the `beamer_presentation` format. Creating Beamer output from R Markdown requires that LaTeX be installed. R Markdown documents can have optional metadata that is used to generate a document header that includes the title, author, and date. For more details see the documentation on R Markdown metadata. R Markdown documents also support citations. You can find more information on the markdown syntax for citations in the Bibliographies and Citations article in the online documentation. ### Value R Markdown output format to pass to `render()` ### Examples ```R library(rmarkdown) # simple invocation render("pres.Rmd", beamer_presentation()) # specify an option for incremental rendering render("pres.Rmd", beamer_presentation(incremental = TRUE)) ``` ``` -------------------------------- ### Run a Shiny Document with R Markdown Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Use the run function to start a Shiny server for an R Markdown document and render it for display. Auto-reloading is enabled by default. ```r run( file = "index.Rmd", dir = dirname(file), default_file = NULL, auto_reload = TRUE, shiny_args = NULL, render_args = NULL ) ``` -------------------------------- ### Render R Markdown to PDF Document Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Use the `render` function with `pdf_document()` to create PDF output. LaTeX must be installed. Options for the LaTeX engine and Pandoc arguments can be specified. ```R library(rmarkdown) # simple invocation render("input.Rmd", pdf_document()) # specify an option for latex engine render("input.Rmd", pdf_document(latex_engine = "lualatex")) # add a table of contents and pass an option to pandoc render("input.Rmd", pdf_document(toc = TRUE, "--listings")) ``` -------------------------------- ### List Available R Markdown Templates Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Lists available R Markdown templates by name from a specified package, which can be used with `draft()` to create new documents. Set `full_path = TRUE` to get the full path to templates. ```R available_templates(package = "rmarkdown", full_path = FALSE) ``` ```R # List rmarkdown templates & create a draft available_templates() # List rticles templates available_templates("rticles") ``` -------------------------------- ### Render R Markdown to ConTeXt Document Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Use this function to render an R Markdown file to a ConTeXt document. Ensure ConTeXt is installed. ```R library(rmarkdown) # simple invocation render("input.Rmd", context_document()) ``` -------------------------------- ### pdf_document Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html R Markdown output format for creating PDF documents. Requires LaTeX installation. Supports customizable metadata for headers, fonts, colors, and layout. ```APIDOC ## pdf_document ### Description Output format for creating PDF documents from R Markdown. Requires LaTeX. Supports customizable metadata for document properties like title, author, date, font size, margins, and LaTeX engine. ### Usage ```R pdf_document(toc = FALSE, toc_depth = 2, number_sections = FALSE, fontsize = 11pt, geometry = "margin=1in", lang = "en", documentclass = "article", classoption = NULL, mainfont = NULL, sansfont = NULL, monofont = NULL, mathfont = NULL, linkcolor = "black", urlcolor = "black", citecolor = "black", linestretch = NULL, fig_width = 5, fig_height = 4, fig_caption = TRUE, md_extensions = NULL, pandoc_args = NULL, header_includes = NULL, includes = NULL, before_body = NULL, after_body = NULL, latexd_engine = "pdflatex", keep_tex = FALSE, highlight = "default", template = NULL, citation_package = "default", ...) ``` ### Arguments * `toc` (boolean) - Whether to include a table of contents. * `toc_depth` (integer) - Depth of table of contents. * `number_sections` (boolean) - Whether to number sections. * `fontsize` (string) - Font size (e.g., "10pt", "11pt", "12pt"). * `geometry` (string or list) - Options for the geometry class (e.g., "margin=1in"). * `lang` (string) - Document language code (e.g., "es", "fr", "pt-BR"). * `documentclass` (string) - LaTeX document class (e.g., "article"). * `classoption` (string or list) - Option for `documentclass`. * `mainfont`, `sansfont`, `monofont`, `mathfont` (string) - Document fonts (requires XeLaTeX or LuaLaTeX). * `linkcolor`, `urlcolor`, `citecolor` (string) - Color for links and citations. * `linestretch` (string or number) - Options for line spacing. * `fig_width`, `fig_height` (number) - Default figure width and height in inches. * `fig_caption` (boolean) - Whether to include figure captions. * `md_extensions` (list) - Pandoc Markdown extensions. * `pandoc_args` (list) - Additional arguments to pass to Pandoc. * `latexd_engine` (string) - LaTeX engine to use (e.g., "pdflatex", "lualatex"). ### Value An R Markdown output format object. ### Examples ```R # Simple invocation render("input.Rmd", pdf_document()) # Specify a LaTeX engine render("input.Rmd", pdf_document(latex_engine = "lualatex")) # Add a table of contents and pass Pandoc arguments render("input.Rmd", pdf_document(toc = TRUE, "--listings")) ``` ``` -------------------------------- ### Run Shiny Document Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html The `run` function runs a Shiny document by starting a Shiny server associated with the document. It can be used to configure the server and automatically reload the document on changes. ```APIDOC ## rmarkdown::run ### Description Runs a Shiny document by starting an associated Shiny server. The document will be rendered and automatically re-rendered on changes if `auto_reload` is `TRUE`. It supports linking to other documents within the same directory and has a specific logic for determining the default document to serve. ### Arguments - `file` (character(1)) - The initial document to be rendered and viewed. Defaults to a logic-based selection if not specified. - `dir` (character(1)) - The directory containing the R Markdown documents. Defaults to the current working directory. - `shiny_args` (list) - Arguments to configure the Shiny server. See `runApp` documentation for details. - `auto_reload` (logical(1)) - If `TRUE`, saving the document will trigger a re-render. Defaults to `FALSE`. - `default_file` (character(1)) - Specifies the default document to serve if none is provided in the URL or `file` argument. ### Value Invisible NULL. ### Note Unlike `render`, `run` does not render the document to a file on disk. A web browser is usually started automatically to view the document. When using an external web browser, specify the R Markdown filename in the URL (e.g., `http://127.0.0.1:1234/foo.Rmd`). A URL without a filename will show the `default_file`. ### Examples ```R # Run the Shiny document "index.Rmd" in the current directory rmarkdown::run() # Run the Shiny document "shiny_doc.Rmd" on port 8241 rmarkdown::run("shiny_doc.Rmd", shiny_args = list(port = 8241)) ``` ``` -------------------------------- ### YAML Configuration for Custom Site Generator Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Specify a custom site generator function in your index.Rmd or index.md file using the 'site:' field. This example shows the basic YAML structure. ```yaml title: "My Book" output: bookdown::gitbook site: bookdown::bookdown_site ``` -------------------------------- ### Get Pandoc Executable Path Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Retrieves the path to the Pandoc executable used by the rmarkdown package. This is useful for verifying the Pandoc installation or for direct command-line usage. ```R pandoc_exec() ``` -------------------------------- ### Get Lua Filter Paths from R Package Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Retrieves the full paths of Lua filters within an installed R package. By default, it looks for filters in the 'rmarkdown' package's 'inst/rmarkdown/lua' directory. ```R pkg_file_lua(filters = NULL, package = "rmarkdown") ``` ```R pkg_file_lua(c("pagebreak.lua", "latex_div.lua")) ``` -------------------------------- ### Enable Presenter Mode Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Append '?presentme=true' to the presentation URL to enable presenter mode. This opens a separate presenter window that stays in sync with the main presentation. ```html mypresentation.html?presentme=true ``` -------------------------------- ### pkg_file_lua Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Retrieves the full paths of Lua filters within an R package's installed directory structure. ```APIDOC ## pkg_file_lua ### Description Finds the full paths of Lua filters stored in an R package. Lua filters in the 'inst/rmarkdown/lua' directory of a source package are installed to the 'rmarkdown/lua' directory within the installed package. ### Usage ```R pkg_file_lua(filters = NULL, package = "rmarkdown") ``` ### Arguments * `filters` (character vector or NULL) - Filenames of Lua filters to retrieve. If NULL, all filters in the specified folder are returned. * `package` (string) - The name of the R package to search within. Defaults to "rmarkdown". ### Value A character vector of absolute file paths for the specified Lua filters from the package. Paths are processed by `pandoc_path_arg()` for Pandoc compatibility. ### Examples ```R # List all Lua filters in the rmarkdown package pkg_file_lua() # Get paths for specific filters pkg_file_lua(c("pagebreak.lua", "latex_div.lua")) ``` ``` -------------------------------- ### Create navbar HTML Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Creates a navbar HTML file from a navbar definition or a list of links. ```APIDOC ## Create a navbar HTML file from a navbar definition ### Description Create a navbar HTML file from a navbar definition ### Usage ``` navbar_html(navbar) navbar_links_html(links) ``` ### Arguments `navbar` | Navbar definition ---|--- `links` | List of navbar links ### Value Path to temporary file with navbar definition ``` -------------------------------- ### Configure PDF Output Options Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Add options like `toc` (table of contents) and `highlight` (syntax highlighting theme) to the `pdf_document` format in the YAML front-matter. ```yaml output: pdf_document: toc: true highlight: zenburn ``` -------------------------------- ### Configure GitHub Flavored Markdown Output Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Sets up conversion from R Markdown to GitHub Flavored Markdown. Options control table of contents, section numbering, figure dimensions, and math rendering. ```r github_document( toc = FALSE, toc_depth = 3, number_sections = FALSE, math_method = "default", preserve_yaml = FALSE, fig_width = 7, fig_height = 5, dev = "png", df_print = "default", includes = NULL, md_extensions = NULL, hard_line_breaks = TRUE, pandoc_args = NULL, html_preview = TRUE, keep_html = FALSE ) ``` -------------------------------- ### render Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Render the input file to the specified output format using pandoc. If the input requires knitting then `knit` is called prior to pandoc. ```APIDOC ## Render R Markdown ### Description Render the input file to the specified output format using pandoc. If the input requires knitting then `knit` is called prior to pandoc. ### Usage ```R render( input, output_format = NULL, output_file = NULL, output_dir = NULL, output_options = NULL, output_yaml = NULL, intermediates_dir = NULL, knit_root_dir = NULL, runtime = c("auto", "static", "shiny", "shinyrmd", "shiny_prerendered"), clean = TRUE, params = NULL, knit_meta = NULL, envir = parent.frame(), run_pandoc = TRUE, quiet = FALSE, encoding = "UTF-8" ) ``` ``` -------------------------------- ### Transform Path for Pandoc Command Line Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Prepares a file path for use with Pandoc on the command line. Handles path expansion and Windows-specific transformations like short path names and backslashes. ```R pandoc_path_arg(path, backslash = TRUE) ``` -------------------------------- ### Create HTML Base Output Format Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Use `html_document_base` to create a base HTML output format. It's suitable for the `base_format` argument in `output_format`. Configure themes, self-contained output, math rendering, and Pandoc arguments. ```R html_document_base( theme = NULL, self_contained = TRUE, lib_dir = NULL, math_method = "default", mathjax = "default", pandoc_args = NULL, template = "default", dependency_resolver = NULL, copy_resources = FALSE, extra_dependencies = NULL, css = NULL, bootstrap_compatible = FALSE, ... ) ``` -------------------------------- ### Run Shiny App for Parameter Configuration Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Use `knit_params_ask` to launch a Shiny application that prompts the user for parameter configuration for an R Markdown document. This function is useful when you need to dynamically set parameters before knitting. ```r knit_params_ask( file = NULL, input_lines = NULL, params = NULL, shiny_args = NULL, save_caption = "Save", encoding = "UTF-8" ) ``` -------------------------------- ### Configure Math Support for github_document Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Specifies how math equations should be rendered in a github_document. Use 'webtex' for image-based rendering, with an option to use SVG for better quality. ```yaml output: github_document: math_method: engine: webtex url: https://latex.codecogs.com/svg.image? ``` -------------------------------- ### Custom CSS for Anchor Section Icons Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Apply custom CSS to modify the appearance of anchor section links, such as using a specific pictogram. This example uses a Unicode character for a link symbol. ```css a.anchor-section::before { content: '\01F517'; } ``` -------------------------------- ### Basic ioslides Presentation Structure Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Use this structure to create a basic slide show with sections and slides. Sections are defined by `#` and slides by `##`. ```markdown --- title: "Habits" author: John Doe date: March 22, 2005 output: ioslides_presentation --- # In the morning ## Getting up - Turn off alarm - Get out of bed ## Breakfast - Eat eggs - Drink coffee # In the evening ## Dinner - Eat spaghetti - Drink wine ---------- ![picture of spaghetti](images/spaghetti.jpg) ## Going to sleep - Get in bed - Count sheep ``` -------------------------------- ### List R Markdown Dependencies Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Use knitr::knit_meta to list available dependencies. Note that duplicated names are handled by merging only the first occurrence. ```r str(knitr::knit_meta("output_format_dependency", clean = FALSE)) ``` -------------------------------- ### render_site, clean_site, site_generator, site_config, default_site_generator Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Functions for rendering multiple R Markdown documents as a website, cleaning site artifacts, generating site structures, and configuring site settings. ```APIDOC ## Render multiple documents as a website ### Description Render all of the R Markdown documents within a directory as a website. ### Usage ```R render_site( input = ".", output_format = "all", envir = parent.frame(), quiet = FALSE, encoding = "UTF-8" ) clean_site(input = ".", preview = TRUE, quiet = FALSE, encoding = "UTF-8") site_generator(input = ".", output_format = NULL) site_config(input = ".", encoding = "UTF-8") default_site_generator(input, output_format_filter = NULL, ...) ``` ### Arguments * `input` (character(1)) - Path to the directory containing R Markdown files. * `output_format` (character() or NULL) - The output format(s) to render for the site. Defaults to "all". * `envir` (environment) - Environment in which to evaluate R code. * `quiet` (logical(1)) - If TRUE, suppresses output messages. * `encoding` (character(1)) - Encoding of the input files. * `preview` (logical(1)) - For `clean_site`, whether to preview the files to be removed. * `...` - Additional arguments passed to `default_site_generator`. ### Details These functions provide a framework for building websites from collections of R Markdown documents. `render_site` processes all Rmd files in a directory, `clean_site` removes generated site files, `site_generator` creates a site generator object, `site_config` reads site configuration, and `default_site_generator` provides a default implementation for site generation. ``` -------------------------------- ### Convert IPython Notebook to R Markdown Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Illustrates the conversion of an IPython notebook's JSON data structure to an R Markdown file. This process involves creating a mock notebook file and then using the `convert_ipynb` function. Warnings may be issued for IPython-specific features like line magics. ```R # this is not a real ipynb file, but illustrates what convert_ipynb() does nb_data <- list( cells = list( list(cell_type = 'markdown', source = 'Hi **Markdown**!'), list(cell_type = 'code', source = 'print("Hi R Markdown!")') ), metadata = list( kernelspec = list(language = 'python') ) ) nb_file = tempfile(fileext = '.ipynb') jsonlite::write_json(nb_data, nb_file, auto_unbox = TRUE, pretty = TRUE) xfun::file_string(nb_file) # show file content # convert to R Markdown nb_rmd = rmarkdown:::convert_ipynb(nb_file) xfun::file_string(nb_rmd) ``` -------------------------------- ### Configure ioslides Presentation Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Format R Markdown content as an ioslides presentation with various customization options for sections, figures, and appearance. ```r ioslides_presentation( number_sections = FALSE, logo = NULL, slide_level = 2, incremental = FALSE, fig_width = 7.5, fig_height = 4.5, fig_retina = 2, fig_caption = TRUE, dev = "png", df_print = "default", smart = TRUE, self_contained = TRUE, widescreen = FALSE, smaller = FALSE, transition = "default", math_method = "mathjax", mathjax = "default", analytics = NULL, template = NULL, css = NULL, includes = NULL, keep_md = FALSE, lib_dir = NULL, md_extensions = NULL, pandoc_args = NULL, extra_dependencies = NULL, ... ) ``` -------------------------------- ### ConTeXt Document Format Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Format for converting R Markdown documents to PDF using ConTeXt. ```APIDOC ## Convert to a ConTeXt document ### Description Format for converting from R Markdown to PDF using ConTeXt. ### Usage ```R context_document( toc = FALSE, toc_depth = 2, number_sections = FALSE, fig_width = 6.5, fig_height = 4.5, fig_crop = "auto", fig_caption = TRUE, dev = "pdf", df_print = "default", template = NULL, keep_tex = FALSE, keep_md = FALSE, citation_package = c("default", "natbib", "biblatex"), includes = NULL, md_extensions = NULL, output_extensions = NULL, pandoc_args = NULL, context_path = NULL, context_args = NULL, ext = c(".pdf", ".tex") ) ``` ``` -------------------------------- ### Create Slidy Presentation Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Use `slidy_presentation()` to create HTML-based slide shows. Options like `incremental = TRUE` can control slide transitions. ```R library(rmarkdown) # simple invocation render("pres.Rmd", slidy_presentation()) # specify an option for incremental rendering render("pres.Rmd", slidy_presentation(incremental = TRUE)) ``` -------------------------------- ### site_resources Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Determine website resource files for a directory. ```APIDOC ## site_resources ### Description Determine which files within a given directory should be copied in order to serve a website from the directory. Attempts to automatically exclude source, data, hidden, and other files not required to serve website content. ### Usage ```R site_resources(site_dir, include = NULL, exclude = NULL, recursive = FALSE) ``` ### Arguments - `site_dir` (character) - Site directory to analyze - `include` (character vector, optional) - Additional files to include (glob wildcards supported) - `exclude` (character vector, optional) - Files to exclude (glob wildcards supported) - `recursive` (logical) - `TRUE` to return a full recursive file listing; `FALSE` to just provide top-level files and directories. ### Value Character vector of files and directories to copy. ``` -------------------------------- ### Specify Multiple Output Formats Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Define multiple output formats in the YAML front-matter. The `render` function will use the first one if no specific format is provided. ```yaml output: pdf_document: toc: true highlight: zenburn html_document: toc: true theme: united ``` -------------------------------- ### Configure KaTeX Math Rendering in R Markdown Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Specify KaTeX as the math rendering engine and provide a CDN URL for its assets. This configuration is used within the YAML header of an R Markdown document. ```yaml output: html_document: math_method: engine: katex url: https://cdn.jsdelivr.net/npm/katex@0.15.2/dist/ ``` -------------------------------- ### github_document format arguments Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Configuration options for the github_document output format in R Markdown. ```APIDOC ## github_document format arguments ### Description Arguments for the `github_document()` format. ### Arguments - `toc` (boolean): `TRUE` to include a table of contents in the output. - `toc_depth` (integer): Depth of headers to include in table of contents. - `number_sections` (boolean): `TRUE` to number section headings. - `math_method` (string | null): Method for math rendering. Options include `"default"` (Github support), `"webtex"` (render to image), or `NULL` to opt-out. - `preserve_yaml` (boolean): Preserve YAML front matter in the final document. - `fig_width` (numeric): Default width (in inches) for figures. - `fig_height` (numeric): Default height (in inches) for figures. - `dev` (string): Graphics device to use for figure output (defaults to png). - `df_print` (string | function): Method for printing data frames. Valid values include "default", "kable", "tibble", and "paged", or an arbitrary function. Can be disabled by setting `rmarkdown.df_print` to `FALSE`. - `includes` (list): Named list of additional content to include within the document. - `md_extensions` (list): Markdown extensions to be added or removed from the default definition of R Markdown. - `hard_line_breaks` (boolean): `TRUE` to generate markdown that uses a simple newline to represent a line break. - `pandoc_args` (list): Additional command line options to pass to pandoc. - `html_preview` (boolean): `TRUE` to also generate an HTML file for local preview on GitHub. - `keep_html` (boolean): `TRUE` to keep the preview HTML file. Default is `FALSE`. ### Details See the online documentation for additional details on using the `github_document()` format. ### Value R Markdown output format to pass to `render()` ### About Math support Default behavior is to keep any inline equation using `$` and any block equation using `$$` in the resulting markdown as Github will process those using Mathjax. **This feature is only available with Pandoc 2.10.1 and above** When using `"webtex"`, PNG images with a white background are used by default so that it shows correctly on Github on both light and dark theme. You can choose to only output SVG for better quality by changing the URL used: ``` output: github_document: math_method: engine: webtex url: https://latex.codecogs.com/svg.image? ``` Background or fonts color cannot be changed for now and your equation may not be visible on dark theme. Using `"webtex"` will be the default with Pandoc 2.0.4 until Pandoc 2.10. Before 2.0.4, Github document output does not support math. ``` -------------------------------- ### ioslides_presentation() format Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Format for converting from R Markdown to an ioslides presentation. ```APIDOC ## Convert to an ioslides Presentation ### Description Format for converting from R Markdown to an ioslides presentation. ### Usage ```R ioslides_presentation( number_sections = FALSE, logo = NULL, slide_level = 2, incremental = FALSE, fig_width = 7.5, fig_height = 4.5, fig_retina = 2, fig_caption = TRUE, dev = "png", df_print = "default", smart = TRUE, self_contained = TRUE, widescreen = FALSE, smaller = FALSE, transition = "default", math_method = "mathjax", mathjax = "default", analytics = NULL, template = NULL, css = NULL, includes = NULL, keep_md = FALSE, lib_dir = NULL, md_extensions = NULL, pandoc_args = NULL, extra_dependencies = NULL, ... ) ``` ``` -------------------------------- ### Create Navbar HTML Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Functions to create HTML files for navigation bars from a navbar definition or a list of links. ```R navbar_html(navbar) ``` ```R navbar_links_html(links) ``` -------------------------------- ### List available R Markdown template in a package Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Lists the available R Markdown templates within a specified package that can be used with the `draft()` function to create new documents. ```APIDOC ## available_templates ### Description List the available template by name that can be used with `draft()` to create a new document for R Markdown from a package. ### Usage ``` available_templates(package = "rmarkdown", full_path = FALSE) ``` ### Arguments `package` | Package to list template from. Default to **rmarkdown** `full_path` | Set to `TRUE` to get the full path to the available templates ### Value A character vector of templates name to use within `draft()`. If `full_path = TRUE`, it returns the full path to the templates. ### Examples ```R # List rmarkdown templates & create a draft available_templates() # List rticles templates available_templates("rticles") ``` ``` -------------------------------- ### Check Pandoc Availability and Version Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Functions to determine if Pandoc is available on the system and to retrieve its version. ```APIDOC ## pandoc_available ### Description Determine whether pandoc is currently available on the system (optionally checking for a specific version or greater). Determine the specific version of pandoc available. ### Usage ```R pandoc_available(version = NULL, error = FALSE) pandoc_version() ``` ### Arguments - `version` (string): Required version of pandoc. - `error` (boolean): Whether to signal an error if pandoc with the required version is not found. ### Details The system environment variable `PATH` as well as the version of pandoc shipped with RStudio are scanned for pandoc and the highest version available is used. ### Value `pandoc_available` returns a logical indicating whether the required version of pandoc is available. `pandoc_version` returns a `numeric_version` with the version of pandoc found. ``` -------------------------------- ### Render R Markdown with Options Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Specify additional options for output formats, such as a table of contents for HTML or a specific LaTeX engine for PDF. ```R render("input.Rmd", html_document(toc = TRUE)) render("input.Rmd", pdf_document(latex_engine = "lualatex")) render("input.Rmd", beamer_presentation(incremental = TRUE)) ``` -------------------------------- ### Render supporting files for an input document Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Renders (copies) required supporting files for an input document to the `_files` directory associated with the document. ```APIDOC ## render_supporting_files ### Description Render (copy) required supporting files for an input document to the `_files` directory that is associated with the document. ### Usage ```R render_supporting_files(from, files_dir, rename_to = NULL) ``` ### Arguments `from` | The directory from which the files should be copied. ---|--- `files_dir` | The directory that will receive the copied files. `rename_to` | An option to rename the source directory after the copy operation is complete. ### Value The relative path to the supporting files. This path is suitable for inclusion in HTML`href` and `src` attributes. ``` -------------------------------- ### Configure Navigation Bar with YAML Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Define a global navigation bar for HTML documents by including a _navbar.yml file. Specify title, type, and menu items for left and right sides. ```yaml title: "My Website" type: default left: - text: "Home" href: index.html - text: "Other" href: other.html right: - text: GitHub href: https://github.com ``` -------------------------------- ### Render Site Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Use `render_site` to render all R Markdown documents in a directory as a website. `clean_site` removes generated files, and `site_generator` and `site_config` manage site structure. ```r render_site( input = ".", output_format = "all", envir = parent.frame(), quiet = FALSE, encoding = "UTF-8" ) clean_site(input = ".", preview = TRUE, quiet = FALSE, encoding = "UTF-8") site_generator(input = ".", output_format = NULL) site_config(input = ".", encoding = "UTF-8") default_site_generator(input, output_format_filter = NULL, ...) ``` -------------------------------- ### slidy_presentation Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Format for converting from R Markdown to a slidy presentation. ```APIDOC ## slidy_presentation ### Description Format for converting from R Markdown to a slidy presentation. ### Usage ```R slidy_presentation( number_sections = FALSE, incremental = FALSE, slide_level = NULL, duration = NULL, footer = NULL, font_adjustment = 0, fig_width = 8, fig_height = 6, fig_retina = 2, fig_caption = TRUE, dev = "png", df_print = "default", self_contained = TRUE, highlight = "default", math_method = "default", mathjax = "default", template = "default", css = NULL, includes = NULL, keep_md = FALSE, lib_dir = NULL, md_extensions = NULL, pandoc_args = NULL, extra_dependencies = NULL, ... ) ``` ### Arguments - `number_sections` (logical) - Whether to number sections. - `incremental` (logical) - Whether to use incremental display for slides. - `slide_level` (integer, optional) - The heading level to use for slides. - `duration` (numeric, optional) - Estimated duration for the presentation in minutes. - `footer` (character, optional) - Text to include in the slide footer. - `font_adjustment` (numeric) - Adjustment for font size. - `fig_width` (numeric) - Default figure width. - `fig_height` (numeric) - Default figure height. - `fig_retina` (numeric) - Resolution factor for retina displays. - `fig_caption` (logical) - Whether to render figure captions. - `dev` (character) - Graphics device to use for figures. - `df_print` (character) - How to print data frames. - `self_contained` (logical) - Whether the output should be self-contained. - `highlight` (character) - Syntax highlighting style. - `math_method` (character) - Method for rendering math. - `mathjax` (character) - MathJax configuration. - `template` (character) - Slide template. - `css` (character vector, optional) - CSS files to include. - `includes` (list, optional) - Includes for various parts of the document. - `keep_md` (logical) - Whether to keep the intermediate markdown file. - `lib_dir` (character) - Directory for supporting files. - `md_extensions` (character vector, optional) - Pandoc markdown extensions. - `pandoc_args` (character vector, optional) - Additional arguments for Pandoc. - `extra_dependencies` (list, optional) - Additional dependencies for the output format. - `...` - Additional arguments passed to the output format. ``` -------------------------------- ### slidy_presentation Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html R Markdown output format for creating Slidy web presentations. ```APIDOC ## slidy_presentation ### Description See the online documentation for additional details on using the `slidy_presentation` format. For more information on markdown syntax for presentations see the pandoc online documentation. ### Value R Markdown output format to pass to `render` ### Examples ```R ## Not run: library(rmarkdown) # simple invocation render("pres.Rmd", slidy_presentation()) # specify an option for incremental rendering render("pres.Rmd", slidy_presentation(incremental = TRUE)) ## End(Not run) ``` ``` -------------------------------- ### Create Beamer Presentation Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Formats R Markdown content for conversion into a Beamer presentation. Allows customization of various presentation elements like table of contents, slide levels, themes, and LaTeX engine. ```R beamer_presentation( toc = FALSE, slide_level = NULL, number_sections = FALSE, incremental = FALSE, fig_width = 10, fig_height = 7, fig_crop = "auto", fig_caption = TRUE, dev = "pdf", df_print = "default", theme = "default", colortheme = "default", fonttheme = "default", highlight = "default", template = "default", keep_tex = FALSE, keep_md = FALSE, latex_engine = "pdflatex", citation_package = c("default", "natbib", "biblatex"), self_contained = TRUE, includes = NULL, md_extensions = NULL, pandoc_args = NULL, extra_dependencies = NULL ) ``` -------------------------------- ### Render Supporting Files Function Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Copies required supporting files for an R Markdown document to a specified directory. The 'files_dir' argument is the destination, and 'rename_to' can optionally rename the source directory after copying. ```r render_supporting_files(from, files_dir, rename_to = NULL) ``` -------------------------------- ### Create LaTeX Document Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html The `latex_document` function is used for generating LaTeX output. Pass relevant arguments to customize the document. ```R latex_document(...) ``` -------------------------------- ### publish_site Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Publish a website to RStudio Connect. ```APIDOC ## publish_site ### Description Publish a website to RStudio Connect ### Usage ```R publish_site( site_dir = ".", site_name = NULL, method = c("rsconnect"), server = NULL, account = NULL, render = TRUE, launch_browser = interactive() ) ``` ### Arguments `site_dir` | Directory containing website. Defaults to current working directory. `site_name` | Name for the site (names must be unique within an account). Defaults to the 'name' provided by the site generator (or to the name of the site_dir if there is no 'name' specified). `method` | Publishing method (currently only "rsconnect" is available) `account`, `server` | Uniquely identify a remote server with either your user `account`, the `server` name, or both. If neither are supplied, and there are multiple options, you'll be prompted to pick one. Use `accounts()` to see the full list of available options. `render` | 'TRUE' to render the site locally before publishing. `launch_browser` | If ‘TRUE', the system’s default web browser will be launched automatically after the site is deployed. Defaults to 'TRUE' in interactive sessions only. ### Examples ```R ## Not run: library(rmarkdown) publish_site() ## End(Not run) ``` ``` -------------------------------- ### Widescreen and Smaller Text Options Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Use the `widescreen: true` option for a wider presentation format and `smaller: true` to reduce text size. ```yaml --- output: ioslides_presentation: widescreen: true smaller: true --- ``` -------------------------------- ### Build Slide Content Incrementally Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Add the `.build` attribute to a slide header to display its content incrementally. ```markdown ## Getting up {.build} ``` -------------------------------- ### Render R Markdown to Beamer Presentation Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Use `render()` with `beamer_presentation()` to create Beamer PDF presentations from R Markdown files. Options like `incremental = TRUE` can be passed to customize the output. ```R library(rmarkdown) # simple invocation render("pres.Rmd", beamer_presentation()) # specify an option for incremental rendering render("pres.Rmd", beamer_presentation(incremental = TRUE)) ``` -------------------------------- ### Enable Tabbed Sections with Markdown Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Organize content into tabs by applying the .tabset class attribute to headers. Sub-headers will appear within tabs. ```markdown ## Quarterly Results {.tabset} ### By Product ### By Region ``` -------------------------------- ### Render Pandoc Template Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Uses Pandoc's templating engine to render a text file. Substitutions are performed using a provided list of metadata. Useful for generating custom reports or documents. ```R pandoc_template(metadata, template, output, verbose = FALSE) ``` -------------------------------- ### Render R Markdown with Pandoc Arguments Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Include arbitrary Pandoc command-line arguments when rendering an R Markdown document, for advanced customization. ```R render("input.Rmd", pdf_document(toc = TRUE, pandoc_args = "--listings")) ``` -------------------------------- ### Publish R Markdown Website Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Publishes an R Markdown website to RStudio Connect. Renders the site locally before publishing if specified. Launches the browser upon deployment. ```R publish_site( site_dir = ".", site_name = NULL, method = c("rsconnect"), server = NULL, account = NULL, render = TRUE, launch_browser = interactive() ) ``` ```R library(rmarkdown) publish_site() ``` -------------------------------- ### Include Arguments for Pandoc Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Use these functions to generate Pandoc command-line arguments for including content in headers or bodies, syntax highlighting, specifying LaTeX engines, and managing tables of contents. ```R library(rmarkdown) pandoc_include_args(before_body = "header.htm") pandoc_include_args(before_body = "header.tex") pandoc_highlight_args("kate") pandoc_latex_engine_args("pdflatex") pandoc_toc_args(toc = TRUE, toc_depth = 2) ``` -------------------------------- ### knit_params_ask Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html Runs a Shiny application to ask for parameter configuration for a given R Markdown document. ```APIDOC ## knit_params_ask ### Description Run a shiny application asking for parameter configuration for the given document. ### Usage ```R knit_params_ask( file = NULL, input_lines = NULL, params = NULL, shiny_args = NULL, save_caption = "Save", encoding = "UTF-8" ) ``` ### Arguments - `file` (character): Path to the R Markdown document with configurable parameters. - `input_lines` (character): Content of the R Markdown document. If `NULL`, the contents of `file` will be read. - `params` (list): A named list of optional parameter overrides used in place of the document defaults. - `shiny_args` (list): Additional arguments to `runApp`. - `save_caption` (character): Caption to use for the button that saves/confirms parameters. - `encoding` (character): Ignored. The encoding is always assumed to be UTF-8. ### Value A named list with overridden parameter names and values. ``` -------------------------------- ### powerpoint_presentation Source: https://cran.r-project.org/web/packages/rmarkdown/refman/rmarkdown.html R Markdown output format for converting documents to PowerPoint presentations. Requires Pandoc v2.0.5 or higher. ```APIDOC ## powerpoint_presentation ### Description Format for converting R Markdown documents to PowerPoint presentations. Requires Pandoc version 2.0.5 or higher. ### Usage ```R powerpoint_presentation( toc = FALSE, toc_depth = 2, number_sections = FALSE, incremental = FALSE, fig_width = 5, fig_height = 4, fig_caption = TRUE, df_print = "default", keep_md = FALSE, md_extensions = NULL, slide_level = NULL, reference_doc = "default", pandoc_args = NULL ) ``` ### Arguments * `toc` (boolean) - Whether to include a table of contents. * `toc_depth` (integer) - Depth of the table of contents. * `number_sections` (boolean) - Whether to number sections. * `incremental` (boolean) - Whether to use incremental display for slides. * `fig_width`, `fig_height` (number) - Default figure width and height in inches. * `fig_caption` (boolean) - Whether to include figure captions. * `df_print` (string) - How to print data frames (e.g., "default", "kable"). * `keep_md` (boolean) - Whether to keep the intermediate Markdown file. * `md_extensions` (list) - Pandoc Markdown extensions to apply. * `slide_level` (integer) - The heading level to use for slide breaks. * `reference_doc` (string) - Path to a reference PowerPoint document for styling. * `pandoc_args` (list) - Additional arguments to pass to Pandoc. ### Value An R Markdown output format object for PowerPoint. ```