find_external_resources

0th

Percentile

Find External Resource References

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 = getOption("encoding"))
Arguments
input_file

path to the R Markdown document or HTML file to process

encoding

the encoding of the document

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

Aliases
  • find_external_resources
Documentation reproduced from package rmarkdown, version 1.9, License: GPL-3

Community examples

Looks like there are no examples yet.