fillBlanks(x, blankGrep = c("[ \t]*"), first ="",...)
Arguments
x: character vector
blankGrep: vector of grep patterns, or NA, indicating the type of entry to be considered blank. Each blankGrep pattern is searched using jamba::proigrep(), which by default uses case-insensitive regular expression pattern matching.
first: options character string intended when the first entry of x is blank. By default "" is used.
...: additional parameters are ignored.
Returns
character vector where blank entries are filled with the most recent non-blank value.
Details
This function takes a character vector and fills any blank (missing) entries with the last non-blank entry in the vector. It is intended for situations like imported 'Excel' data, where there may be one header value representing a series of cells.
The method used does not loop through the data, and should scale fairly well with good efficiency even for extremely large vectors.
Examples
x <- c("A","","","","B","C","","",NA,"D","","","E","F","G","","");data.frame(x, fillBlanks(x));
See Also
Other jam string functions: asSize(), breaksByVector(), formatInt(), gsubOrdered(), gsubs(), makeNames(), nameVector(), nameVectorN(), padInteger(), padString(), pasteByRow(), pasteByRowOrdered(), sizeAsNum(), tcount(), ucfirst()