powered by
Sources specific lines from a file
source_lines(file, lines, ...)
The result of source.
source
A character string giving the path to the file to be sourced.
A numeric vector of line numbers to be sourced.
Additional arguments to be passed to source.
This function is borrowed from a gist by christophergandrud.
test_file <- tempfile(fileext = ".R") writeLines(c("# Line 1", "2+2", "# Line 3"), test_file) source_lines(test_file, 1:2, echo=TRUE)
Run the code above in your browser using DataLab