Created
March 25, 2013 18:00
-
-
Save jwijffels/5239198 to your computer and use it in GitHub Desktop.
S3 methods for streaming modelling with R package stream and for data in an ffdf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment