set.seed(42)
rs <- new(RunningStats, na_rm=TRUE)
chunk <- runif(1000)
rs$update(chunk)
object.size(rs)
rs$get_count()
length(chunk)
rs$get_mean()
mean(chunk)
rs$get_min()
min(chunk)
rs$get_max()
max(chunk)
rs$get_var()
var(chunk)
rs$get_sd()
sd(chunk)
# \donttest{
## 10^9 values read in 10,000 chunks
## should take under 1 minute on most PC hardware
for (i in 1:1e4) {
chunk <- runif(1e5)
rs$update(chunk)
}
rs$get_count()
rs$get_mean()
rs$get_var()
object.size(rs)
# }
Run the code above in your browser using DataLab