Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

find_external_resources

Find External Resource References


Description

Given an R Markdown document or HTML file, attempt to determine the set of additional files needed in order to render and display the document.

Usage

find_external_resources(input_file, encoding = "UTF-8")

Arguments

input_file

path to the R Markdown document or HTML file to process

encoding

Ignored. The encoding is always assumed to be UTF-8.

Details

This routine applies heuristics in order to scan a document for possible resource references.

In R Markdown documents, it looks for references to files implicitly referenced in Markdown (e.g. ![alt](img.png)), in the document's YAML header, in raw HTML chunks, and as quoted strings in R code chunks (e.g. read.csv("data.csv")).

Resources specified explicitly in the YAML header for R Markdown documents are also returned. To specify resources in YAML, use the resource_files key:

---
title: My Document
author: My Name
resource_files:
  - data/mydata.csv
  - images/figure.png
---

Each item in the resource_files list can refer to:

  1. A single file, such as images/figure.png, or

  2. A directory, such as resources/data, in which case all of the directory's content will be recursively included, or

  3. A wildcard pattern, such as data/*.csv, in which case all of the files matching the pattern will be included. No recursion is done in this case.

In HTML files (and raw HTML chunks in R Markdown documents), this routine searches for resources specified in common tag attributes, such as <img src="...">, <link href="...">, etc.

In all cases, only resources that exist on disk and are contained in the document's directory (or a child thereof) are returned.

Value

A data frame with the following columns:

path

The relative path from the document to the resource

explicit

Whether the resource was specified explicitly (TRUE) or discovered implicitly (FALSE)

web

Whether the resource is needed to display a Web page rendered from the document


rmarkdown

Dynamic Documents for R

v2.10
GPL-3
Authors
JJ Allaire [aut], Yihui Xie [aut, cre] (<https://orcid.org/0000-0003-0645-5666>), Jonathan McPherson [aut], Javier Luraschi [aut], Kevin Ushey [aut], Aron Atkins [aut], Hadley Wickham [aut], Joe Cheng [aut], Winston Chang [aut], Richard Iannone [aut] (<https://orcid.org/0000-0003-3925-190X>), Andrew Dunning [ctb] (<https://orcid.org/0000-0003-0464-5036>), Atsushi Yasumoto [ctb, cph] (<https://orcid.org/0000-0002-8335-495X>, Number sections Lua filter), Barret Schloerke [ctb], Carson Sievert [ctb] (<https://orcid.org/0000-0002-4958-2844>), Christophe Dervieux [ctb], Devon Ryan [ctb] (<https://orcid.org/0000-0002-8549-0971>), Frederik Aust [ctb] (<https://orcid.org/0000-0003-4900-788X>), Jeff Allen [ctb], JooYoung Seo [ctb] (<https://orcid.org/0000-0002-4064-6012>), Malcolm Barrett [ctb], Rob Hyndman [ctb], Romain Lesur [ctb], Roy Storey [ctb], Ruben Arslan [ctb], Sergio Oller [ctb], RStudio, PBC [cph], jQuery Foundation [cph] (jQuery library), jQuery contributors [ctb, cph] (jQuery library; authors listed in inst/rmd/h/jquery-AUTHORS.txt), jQuery UI contributors [ctb, cph] (jQuery UI library; authors listed in inst/rmd/h/jqueryui-AUTHORS.txt), Mark Otto [ctb] (Bootstrap library), Jacob Thornton [ctb] (Bootstrap library), Bootstrap contributors [ctb] (Bootstrap library), Twitter, Inc [cph] (Bootstrap library), Alexander Farkas [ctb, cph] (html5shiv library), Scott Jehl [ctb, cph] (Respond.js library), Ivan Sagalaev [ctb, cph] (highlight.js library), Greg Franko [ctb, cph] (tocify library), John MacFarlane [ctb, cph] (Pandoc templates), Google, Inc. [ctb, cph] (ioslides library), Dave Raggett [ctb] (slidy library), W3C [cph] (slidy library), Dave Gandy [ctb, cph] (Font-Awesome), Ben Sperry [ctb] (Ionicons), Drifty [cph] (Ionicons), Aidan Lister [ctb, cph] (jQuery StickyTabs), Benct Philip Jonsson [ctb, cph] (pagebreak Lua filter), Albert Krewinkel [ctb, cph] (pagebreak Lua filter)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.