Last active
August 29, 2015 14:22
-
-
Save michaelbarton/8ff0533ec20387c9c0a4 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env Rscript | |
# Assume that the libraries are installed in "../vendor/r/" | |
# Adjust this path to the relative path between the script | |
# and the packrat directory | |
set_package_environment <- function(args){ | |
dir <- dirname(sub("--file=", "", args[grep("--file", args)])) | |
libs <- file.path(dir, "..", "vendor", "r", "packrat", "lib", "*", "*") | |
.libPaths(c(.libPaths(), libs)) | |
} | |
args <- commandArgs(trailingOnly = FALSE) | |
set_package_environment(args) | |
# Load an example package | |
library(tidyr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment