Skip to contents

Sources specific lines from a file

Usage

source_lines(file, lines, ...)

Arguments

file

A character string giving the path to the file to be sourced.

lines

A numeric vector of line numbers to be sourced.

...

Additional arguments to be passed to source.

Value

The result of source.

Examples

test_file <- tempfile(fileext = ".R")
writeLines(c("# Line 1", "2+2", "# Line 3"), test_file)
source_lines(test_file, 1:2, echo=TRUE)
#> 
#> > 2 + 2
#> [1] 4