Skip to content

Instantly share code, notes, and snippets.

@roryk
Last active Dec 10, 2015
Embed
What would you like to do?
# to add latex equations to a Rmd file, enclose the equations using the $ $ syntax
# and run knit_equation on the Rmd file instead of knit
knit_equation = function(rmd, md) {
require('knitr')
require('RCurl')
gist_url = 'https://gist.github.com/roryk/4476421/raw/d08080c206b5663e0451a5ef6c56635a0c6f0f17/gistfile1'
#gist_url = 'https://gist.github.com/raw/4476421/d08080c206b5663e0451a5ef6c56635a0c6f0f17/gistfile1'
tmp = tempfile()
knit(rmd, tmp)
f = file(md, "w")
header = getURL(gist_url, ssl.verifypeer = FALSE)
writeLines(header, f)
writeLines(readLines(tmp), f)
close(f)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment