knitr::opts_chunk$set(echo = TRUE) unlink(list.files(tempdir(), pattern = "\\.bk$", full.names = TRUE)) options(width = 110)
library(bigstatsr) library(foreach) N <- M <- 2000 x4 <- matrix(round(rnorm(N * M, 100, 10)), N) x3 <- x2 <- x1 <- x4 storage.mode(x1) <- "raw" storage.mode(x2) <- "logical" storage.mode(x3) <- "integer" X5 <- big_copy(x4, type = "double") X4 <- big_copy(x4, type = "float") X3 <- big_copy(x4, type = "integer") X2 <- big_copy(x4, type = "unsigned short") X1 <- big_copy(x4, type = "unsigned char") options(bigstatsr.downcast.warning = FALSE) foreach(X = list(X1, X2, X3, X4, X5)) %:% foreach(x = list(x1, x2, x3, x4), .combine = "c") %do% { tmp <- microbenchmark::microbenchmark(X[] <- x) round(median(tmp$time) / 1e6) } options(bigstatsr.downcast.warning = TRUE) foreach(X = list(X1, X2, X3, X4, X5)) %:% foreach(x = list(x1, x2, x3, x4), .combine = "c") %do% { tmp <- microbenchmark::microbenchmark(X[] <- x) round(median(tmp$time) / 1e6) }
library(bigmemory) Y5 <- as.big.matrix(x4, type = "double") Y4 <- as.big.matrix(x4, type = "float") Y3 <- as.big.matrix(x4, type = "integer") Y2 <- as.big.matrix(x4, type = "short") Y1 <- as.big.matrix(x4, type = "char") foreach(X = list(Y1, Y2, Y3, Y4, Y5)) %:% foreach(x = list(x1, x2, x3, x4), .combine = "c") %do% { tmp <- microbenchmark::microbenchmark(X[] <- x, times = 10) round(median(tmp$time) / 1e6) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.