Permalink
Browse files

Add with_lib function

  • Loading branch information...
1 parent a5099b0 commit 7f402b0b814d45dd4669944c38e0efeba6298b8b @wch wch committed Dec 15, 2012
Showing with 16 additions and 1 deletion.
  1. +16 −1 R/with.r
View
@@ -4,7 +4,8 @@
#' \item \code{in_dir}: working directory
#' \item \code{with_collate}: collation order
#' \item \code{with_env}: environmental variables
-#' \item \code{with_libpaths}: library paths
+#' \item \code{with_libpaths}: library paths, replacing current libpaths
+#' \item \code{with_lib}: library paths, prepending to current libpaths
#' \item \code{with_locale}: any locale setting
#' \item \code{with_options}: options
#' \item \code{with_path}: PATH environment variable
@@ -94,6 +95,20 @@ set_libpaths <- function(paths) {
#' @export
with_libpaths <- with_something(set_libpaths)
+# lib ------------------------------------------------------------------------
+
+set_lib <- function(paths) {
+ libpath <- normalizePath(paths, mustWork = TRUE)
+
+ old <- .libPaths()
+ .libPaths(c(libpath, .libPaths()))
+ invisible(old)
+}
+
+#' @rdname with_something
+#' @export
+with_lib <- with_something(set_lib)
+
# options --------------------------------------------------------------------
#' @rdname with_something

0 comments on commit 7f402b0

Please sign in to comment.