Description Usage Arguments Details Value Author(s) Examples
This function repeatedly reads chunkSize
lines of data from
file
and passes a character vector of these strings to
FUN
. The first skip
lines of input are ignored.
1 | hsLineReader(file = "", chunkSize = -1, skip = 0, FUN = function(x) cat(x, sep = "\n"))
|
file |
A connection object or a character string, as in readLines. |
chunkSize |
The (maximal) number of lines to read at a time. The default is -1, which specifies that the whole file should be read at once. |
skip |
Number of lines to ignore at the beginning of the file |
FUN |
A function that takes a character vector as input |
Warning: A feature(?) of readLines is that if there is a newline before the EOF, an extra empty string is returned.
No return value.
David S. Rosenberg. <drosen@sensenetworks.com>
1 2 3 4 5 6 7 8 | str <- "Hello here are some\nlines of text\nto read in, chunkSize\nlines at a time.\nHow interesting.\nhuh?"
cat(str)
con <- textConnection(str, open = "r")
hsLineReader(con,chunkSize=-1,FUN=print)
close(con)
con <- textConnection(str, open = "r")
hsLineReader(con,chunkSize=3,skip=1,FUN=print)
close(con)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.