datastream_file {RMOA} | R Documentation |
File data stream
Description
Reference object of class datastream_file
.
This is a class which inherits from class datastream
and which can be used to read in a stream
from a file. A number of file readers have been implemented, namely
datastream_table
, datastream_csv
, datastream_csv2
,
datastream_delim
, datastream_delim2
.
See the examples.
Arguments
description |
The name how the stream is labelled |
FUN |
The function to use to read in the file.
Defaults to |
columnnames |
optional character vector of column to overwrite the column names of the data read in with in |
file |
The file to read in. See e.g. |
... |
parameters passed on to |
Value
A class of type datastream_file
which contains
- FUN:
The function to use to read in the file
- connection:
A connection to the file
- columnnames:
A character vector of column names to overwrite the column names with in
get_points
- all fields of the datastream superclass:
See
datastream
Methods
-
get_points(n)
Get data from a datastream object.- n
integer, indicating the number of instances to retrieve from the datastream
See Also
read.table
, read.csv
, read.csv2
, read.delim
, read.delim2
Examples
mydata <- iris
mydata$Species[2:3] <- NA
## Example of a CSV file stream
myfile <- tempfile()
write.csv(iris, file = myfile, row.names=FALSE, na = "")
x <- datastream_csv(file = myfile, na.strings = "")
x
x$get_points(n=10)
x
x$get_points(n=10)
x
x$stop()
## Create your own specific file stream
write.table(iris, file = myfile, row.names=FALSE, na = "")
x <- datastream_file(description="My file defintion stream", FUN=read.table,
file = myfile, header=TRUE, na.strings="")
x$get_points(n=10)
x
x$stop()
## Clean up for CRAN
file.remove(myfile)