slurp: Read a file's lines in as vector

Description Usage Arguments Value Warnings

View source: R/stringUtils.R

Description

Essentially a convenience wrapper around readLines. Reads a file's lines into a string vector. Can skip comments if specify a comment string, and drops header line if told to.

Usage

1
slurp(file, commentString = NULL, skipLines = 0)

Arguments

file

The file to read

commentString

If specified, any line beginning with this comment string will be dropped (leading whitespace is ignored). This is parsed as a regualr expression, but that shouldn't be a problem for most normal line comment strings ("#", "##", "//", ";"), leading whitespace is ignored. If null or empty, will be ignored.

skipLines

If specified, skip this many lines at the start of the file. This will be done after comments are filtered, so don't skip headers if they are also comments.

Value

The files content as a string vector, one element per line, including empty lines as empty strings, but excluding filtered lines. If no lines are left after dropping comments and skipping the headers, will return character(0)

Warnings

Skipping more lines, skip, than lines to skip, lines.

There are fewer lines left (after skipping comments) than you asked to skip. Will return character(0) to indicate no kept lines/strings.


jefferys/FusionExpressionPlot documentation built on May 19, 2019, 3:59 a.m.