ConnectionProducer {Streamer} | R Documentation |
ConnectionProducer
classes include ScanProducer
,
ReadLinesProducer
, and ReadTableProducer
, providing
Streamer interfaces to scan
, readLines
, and
read.table
.
ScanProducer(file, ..., fileArgs=list(), scanArgs=list(...)) ReadLinesProducer(con, ..., conArgs=list(), readLinesArgs=list(...)) ReadTableProducer(file, ..., fileArgs=list(), readTableArgs=list(...)) ## S3 method for class 'ConnectionProducer' close(con, ...)
file, con |
The file or connection to be used for input. See
|
... |
Additional arguments, e.g., |
fileArgs, conArgs |
Arguments, e.g., |
scanArgs, readLinesArgs, readTableArgs |
Arguments to
|
See Producer
Methods.
Internal fields of this class are are described with, e.g.,
getRefClass("ReadLinesProducer")$fields
.
Internal methods of this class are described with
getRefClass("ReadLinesProducer")$methods()
and
getRefClass("ReadLinesProducer")$help()
.
Martin Morgan mtmorgan@fhcrc.org
Streamer-package
, Producer-class
,
Streamer-class
.
fl <- system.file(package="Rsamtools", "extdata", "ex1.sam") p <- ReadLinesProducer(fl, n = 1000) # read 1000 lines at a time while (length(y <- yield(p))) print(length(y)) close(p) p <- ReadTableProducer(fl, quote="", fill=TRUE, nrows=1000) while (length(y <- yield(p))) print(dim(y)) reset(p) dim(yield(p)) ## connections opened 'under the hood' are closed, with warnings rm(p); gc() ## avoid warnings by managing connections p <- ScanProducer(file(fl, "r"), verbose=TRUE, scanArgs=list(what=character())) length(yield(p)) close(p) rm(p); gc()