1

I am looking for a guide or example of adding an additional JavaScript file to a rmarkdown output file. I am attempting to create a new rmarkdown template based on the HTML Document template that would include this JavaScript file in all output documents.

From what I have read, I should be able to add an argument to the extra_dependencies parameter. Modelling my additional dependecy after the default html_dependencies. However, when I do so, I receive the following error:

processing file: skeleton.Rmd
output file: skeleton.knit.md

Error in FUN(X[[i]], ...) : subscript out of bounds
Calls: <Anonymous> ... dependency_resolver -> <Anonymous> -> sapply -> lapply
Execution halted

Here is my example:

---
title: "Your Title Here"
author: "Your Name"
output:
  html_document:
    extra_dependencies:
      - list(htmltools::htmlDependency('example', '1.0', src=getwd() + '/static', script='example.js', all_files=FALSE))
---

Hello World!
Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
modelDBA
  • 176
  • 1
  • 8

0 Answers0