Skip to content

Instantly share code, notes, and snippets.

Created April 2, 2019 10:27
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
R function to build a local URL for RMarkdown
localurl <- function(document, path = ""){
path <- str_remove_all(path, "/$|^/")
document <- str_remove_all(document, "/$|^/")
path <- file.path(path, document) %>%
document <- last(str_split(path, pattern = "/", simplify = T))
return(paste0("[", document, "](", path, ")"))
title: "Untitled"
author: "Martin"
date: "2 April 2019"
output: pdf_document
```{r setup, include=FALSE}
We have evidence, see `r localurl("../data/evidence.pdf")`.
We also have more evidence here: `r localurl("moreevidence.pdf", "../data/")`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment