public
Created

S3 methods for streaming modelling with R package stream and for data in an ffdf

  • Download Gist
gistfile1.r
R
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
DSD_FFDFstream <- function(x, k=NA, assignment=NULL, loop=FALSE) {
stopifnot(is.ffdf(x))
open(x)
state <- new.env()
assign("counter", 1L, envir = state)
l <- list(description = "FF Data Stream",
strm = x,
state = state,
d = ncol(x),
k = k,
assignment = assignment,
loop = loop)
class(l) <- c("DSD_FFDFstream","DSD_R","DSD")
l
}
get_points.DSD_FFDFstream <- function(x, ...){
stream:::get_points.DSD_Wrapper(x, ...)
}
print.DSD_FFDFstream <- function(x, ...) {
NextMethod() # calling the super classes print()
pos <- x$state$counter
if (pos>nrow(x$strm))
if (!x$loop) pos <- "'end'" else pos <- 1
cat(paste('Contains', nrow(x$strm),
'data points - currently at position', pos,
'- loop is', x$loop, '\n'))
}
reset_stream.DSD_FFDFstream <- function(dsd) {
stream:::reset_stream.DSD_Wrapper(dsd)
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.