Created
April 2, 2019 10:27
-
-
Save mgei/32102a1c89b49da21516bb2eed80385e to your computer and use it in GitHub Desktop.
R function to build a local URL for RMarkdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
localurl <- function(document, path = ""){ | |
path <- str_remove_all(path, "/$|^/") | |
document <- str_remove_all(document, "/$|^/") | |
path <- file.path(path, document) %>% | |
str_remove_all("/$|^/") | |
document <- last(str_split(path, pattern = "/", simplify = T)) | |
return(paste0("[", document, "](", path, ")")) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Untitled" | |
author: "Martin" | |
date: "2 April 2019" | |
output: pdf_document | |
--- | |
```{r setup, include=FALSE} | |
source(localurl.R) | |
``` | |
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