Skip to content

Instantly share code, notes, and snippets.

@noamross
noamross / source_rmd.R
Last active Apr 22, 2021
Source an RMD file
View source_rmd.R
#' Source the R code from an knitr file, optionally skipping plots
#'
#' @param file the knitr file to source
#' @param skip_plots whether to make plots. If TRUE (default) sets a null graphics device
#'
#' @return This function is called for its side effects
#' @export
source_rmd = function(file, skip_plots = TRUE) {
temp = tempfile(fileext=".R")
knitr::purl(file, output=temp)
@benmarwick
benmarwick / PDF-2-text-or-CSV.r
Last active Apr 2, 2021
Convert PDFs to text files or CSV files (DfR format) with R
View PDF-2-text-or-CSV.r
# Here are a few methods for getting text from PDF files. Do read through
# the instructions carefully! NOte that this code is written for Windows 7,
# slight adjustments may be needed for other OSs
# Tell R what folder contains your 1000s of PDFs
dest <- "G:/somehere/with/many/PDFs"
# make a vector of PDF file names
myfiles <- list.files(path = dest, pattern = "pdf", full.names = TRUE)