strip.blanks: string utility functions

Description Usage Arguments Details Value Author(s) Examples

Description

strip blank characters from the ends of a character string or skip blank lines (or lines with a particular pattern) in a file

Usage

1
2
3

Arguments

str

a character vector

con

an open connection

pattern

a regular expression pattern

blank.ok

skip blank lines as well as lines containing patterns?

Details

skip.blank.lines() and skip.pattern.lines() read lines from a file until the first non-blank line or the first line without a specified pattern then pushes that line back

Value

A character vector with blanks removed (for strip.blanks) or the number of lines skipped (skip.blank.lines or skip.pattern.lines)

Author(s)

Ben Bolker

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
strip.blanks(c("   a ","b","   c "))
tfn = tempfile("test")
tfile = file(tfn,open="w")
writeLines(c("","  ","abc"),tfile)
close(tfile)
tfile=file(tfn,open="r")
skip.blank.lines(tfile)
readLines(tfile)
close(tfile)
unlink(tfn)

bbolker/cpcbp documentation built on May 11, 2019, 9:28 p.m.