Skip to content

Instantly share code, notes, and snippets.

@christophergandrud
Created December 1, 2014 14:08
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save christophergandrud/1eb4e095974204b12af9 to your computer and use it in GitHub Desktop.
Save christophergandrud/1eb4e095974204b12af9 to your computer and use it in GitHub Desktop.
Source specific lines from a file in R
#' Source specific lines in an R file
#'
#' @param file character string with the path to the file to source.
#' @param lines numeric vector of lines to source in \code{file}.
source_lines <- function(file, lines){
source(textConnection(readLines(file)[lines]))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment