get_lines: Read in specified lines from a text file

Description Usage Arguments Details Value See Also Examples

View source: R/textutils.R

Description

Read in specified lines from a text file

Usage

1
get_lines(filename, line_numbers)

Arguments

filename

character containing the filename of the file from which the lines should be read.

line_numbers

A vector containing the lines that should be read.

Details

Line numbers larger than the number of lines in the file are ignored. Missing values are returned for these.

Value

Returns a character vector with the specified lines.

See Also

See readLines to read in all lines a text file; sample_lines can be used to read in random lines.

Examples

1
2
3
4
5
6
7
8
# Create temporary filename
tmpcsv  <- tempfile(fileext="csv")

writeLines(letters[1:20], con=tmpcsv)
get_lines(tmpcsv, c(1, 10))

# Cleanup
file.remove(tmpcsv)

djvanderlaan/LaF documentation built on April 2, 2020, 7:10 a.m.