In this vignette we compare computational requirements (time and memory) of common operations using data.table and tidyverse functions.

Setup

library(data.table)
hostname <- system("hostname",intern=TRUE)
(max.threads <- as.integer(Sys.getenv("SLURM_JOB_CPUS_PER_NODE", "1")))
#> [1] 4
threads.vec <- unique(as.integer(c(1, ceiling(max.threads/2), max.threads)))
seconds.limit <- 1
cache.list <- list()
cache <- function(symbol, code){
  cache.symb <- substitute(symbol)
  suffix <- if(grepl("devel",R.version.string)){
    "devel"
  }else{
    gsub("R version | .*", "", R.version.string)
  }
  cache.dir <- paste0("~/R/atime-cache-",suffix)
  cache.rds <- file.path(cache.dir, paste0(cache.symb, ".RDS"))
  if(file.exists(cache.rds)){
    value <- readRDS(cache.rds)
  }else{
    to.eval <- substitute(code)
    value <- eval(to.eval)
    value$hostname <- hostname
    if(dir.exists(cache.dir))saveRDS(value, cache.rds)
  }
  cache.list[[paste(cache.symb)]] <<- value
  assign(paste(cache.symb), value, parent.frame())
}
aplot <- function(atime.list, my.title, xmax, max.seconds, xlab, color.vec=NULL){
  best.list <- atime::references_best(atime.list)
  blank.dt <- data.table(x=best.list$meas$N[1], y=max.seconds, unit="seconds")
  if(require(ggplot2)){
    hline.df <- with(atime.list, data.frame(seconds.limit, unit="seconds"))
    gg <- ggplot()+
      ggtitle(tit <<- paste(my.title,"on",hostname))+
      theme_bw()+
      geom_blank(aes(
        x, y),
        data=blank.dt)+
      facet_grid(unit ~ ., scales="free")+
      geom_hline(aes(
        yintercept=seconds.limit),
        color="grey",
        data=hline.df)+
      geom_line(aes(
        N, empirical, color=expr.name),
        data=best.list$meas)+
      geom_ribbon(aes(
        N, ymin=q25, ymax=q75, fill=expr.name),
        data=best.list$meas[unit=="seconds"],
        alpha=0.5)+
      scale_x_log10(xlab)+
      scale_y_log10("median line, quartiles band")
    if(!is.null(color.vec)){
      gg <- gg+
        scale_color_manual(values=color.vec)+
        scale_fill_manual(values=color.vec)
    }
    if(require(directlabels)){
      gg+
        directlabels::geom_dl(aes(
          N, empirical, color=expr.name, label=expr.name),
          method="right.polygons",
          data=best.list$meas)+
        theme(legend.position="none")+
        coord_cartesian(xlim=c(NA,xmax))
    }else{
      gg
    }
  }
}

Writing CSV

First we define some code which will be used in all of the writing benchmarks,

atime_write <- function(make.input.fun, fmt){
  grid.args <- list(
    list(THREADS=threads.vec),
    "data.table::fwrite"=quote({
      data.table::setDTthreads(THREADS)
      data.table::fwrite(input, name.list[["fwrite"]], showProgress = FALSE)
    }))
  small.input <- make.input.fun(2,2)
  if(requireNamespace("arrow") && is.data.frame(small.input)){
    grid.args[["write_csv_arrow"]] <- quote({
      arrow::set_cpu_count(THREADS)
      arrow::write_csv_arrow(input, name.list[["write_csv_arrow"]])
    })
  }
  if(requireNamespace("readr") && is.data.frame(small.input)){
    ##readr can't handle matrix input.
    grid.args[["readr::write_csv"]] <- quote({
      readr::write_csv(
        input, name.list[["write_csv"]], progress = FALSE, num_threads = THREADS)
    })
  }
  expr.list <- do.call(atime::atime_grid, grid.args)
  atime::atime(
    N=as.integer(10^seq(0, 6, by=0.5)),
    setup={
      input <- make.input.fun(N)
      name.list <- list()
      for(fun in c("fwrite", "write_csv", "write_csv_arrow", "write.csv")){
        name.list[[fun]] <- file.path(
          tempdir(), sprintf(fmt, fun, N))
      }
    },
    seconds.limit = seconds.limit,
    expr.list=expr.list,
    "utils::write.csv"=utils::write.csv(input, name.list[["write.csv"]]))
}
one.thread <- function(DT)DT[grepl("utils|scan|THREADS=1$", expr.name)]
facetPlot <- function(atime.list, fun.name.vec=c("N^2","N"), N.min=1e2){
  best.list <- atime::references_best(atime.list)
  meas.dt <- one.thread(best.list$meas)
  ref.dt <- one.thread(best.list$ref)[
    fun.name %in% fun.name.vec & N >= N.min]
  if(require(ggplot2)){
    hline.df <- with(write.real.vary.rows, data.frame(
      seconds.limit, unit="seconds"))
    gg <- ggplot()+
      ggtitle(paste0(tit,", asymptotic complexity"))+
      theme_bw()+
      facet_grid(unit ~ expr.name, scales="free")+
      geom_hline(aes(
        yintercept=seconds.limit),
        color="grey",
        data=hline.df)+
      geom_line(aes(
        N, reference, group=paste(expr.name, fun.name)),
        linewidth=2,
        data=ref.dt)+
      geom_line(aes(
        N, empirical, color=expr.name),
        linewidth=1,
        data=meas.dt)+
      geom_ribbon(aes(
        N, ymin=q25, ymax=q75, fill=expr.name),
        data=meas.dt[unit=="seconds"],
        alpha=0.5)+
      scale_x_log10("N = Number of columns")+
      scale_y_log10("median line, quartiles band")+
      scale_color_manual(values=write.colors)+
      scale_fill_manual(values=write.colors)
    if(require(directlabels)){
      gg+
        directlabels::geom_dl(aes(
          N, reference,
          label.group=paste(expr.name, fun.name),
          label=fun.name),
          method="left.polygons",
          data=ref.dt)+
        theme(legend.position="none")
    }else{
      gg
    }
  }
}
if(FALSE){
  RColorBrewer::display.brewer.all()
  dput(RColorBrewer::brewer.pal(Inf, "Set2"))
  dput(RColorBrewer::brewer.pal(Inf, "RdGy"))
}
NAME <- function(prefix, ...){
  structure(
    c(...)[1:length(threads.vec)],
    names=sprintf("%sTHREADS=%d", prefix, threads.vec))
}
write.colors <- c(
  NAME("readr::write_csv ", "#9970AB","#762A83", "#40004B"), #purple
  "#5AAE61", "#1B7837", "#00441B",#green
  NAME("data.table::fwrite ", "#D6604D", "#B2182B", "#67001F"),#reds
  "#878787", "#4D4D4D", "#1A1A1A",#greys
  NAME("write_csv_arrow ", "#BF812D", "#8C510A", "#543005"),#browns
  "#35978F", "#01665E", "#003C30",#teal polars
  "utils::write.csv"="deepskyblue")
(write.colors <- write.colors[names(write.colors)!=""])
#>   readr::write_csv THREADS=1   readr::write_csv THREADS=2 
#>                    "#9970AB"                    "#762A83" 
#>   readr::write_csv THREADS=4 data.table::fwrite THREADS=1 
#>                    "#40004B"                    "#D6604D" 
#> data.table::fwrite THREADS=2 data.table::fwrite THREADS=4 
#>                    "#B2182B"                    "#67001F" 
#>    write_csv_arrow THREADS=1    write_csv_arrow THREADS=2 
#>                    "#BF812D"                    "#8C510A" 
#>    write_csv_arrow THREADS=4             utils::write.csv 
#>                    "#543005"                "deepskyblue"

Writing CSV with real numbers

The code below is for real numbers with a constant number of columns, and a variable number of rows.

random_real <- function(N.rows, N.cols){
  set.seed(1)
  matrix(rnorm(N.rows*N.cols), N.rows, N.cols)
}
cache(write.real.vary.rows, atime_write(
  function(N.rows, N.cols=10)random_real(N.rows, N.cols),
  "10_real_cols_%s_%d.csv"))
#> Loading required namespace: arrow
#> Loading required namespace: readr
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> Warning: Some expressions had a GC in every iteration; so filtering is
#> disabled.
aplot(write.real.vary.rows, "Write CSV with 10 random normal real columns", 1e9, 1e1, "Number of rows", write.colors)
#> Loading required package: ggplot2
#> Loading required package: directlabels
#> Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
#> logical.return = TRUE, : there is no package called 'directlabels'
#> Warning: Transformation introduced infinite values in continuous y-axis

The plot above shows that all methods are the same, except utils::write.csv memory is increasing with data size, and others are contant.

facetPlot(write.real.vary.rows)
#> Loading required package: directlabels
#> Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
#> logical.return = TRUE, : there is no package called 'directlabels'
#> Warning: Transformation introduced infinite values in continuous y-axis

The plot above shows that the memory usage of utils::write.csv is linear.

The code below writes real numbers with a constant number of rows, and a variable number of columns.

cache(write.real.vary.cols, atime_write(
  function(N.cols, N.rows=10)random_real(N.rows, N.cols),
  "10_real_rows_%s_%d.csv"))
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> Warning: Some expressions had a GC in every iteration; so filtering is
#> disabled.
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> Warning: Some expressions had a GC in every iteration; so filtering is
#> disabled.
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> Warning: Some expressions had a GC in every iteration; so filtering is
#> disabled.
aplot(write.real.vary.cols, "Write CSV with 10 random normal real rows", 1e9, 1e1, "Number of columns", write.colors)
#> Loading required package: directlabels
#> Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
#> logical.return = TRUE, : there is no package called 'directlabels'
#> Warning: Transformation introduced infinite values in continuous y-axis

The plot above shows that data.table::fread uses asymptotically less time and memory than the others.

Write CSV from character matrix

The code below is for a character data matrix with a constant number of columns, and a variable number of rows.

chr_mat <- function(N.rows, N.cols){
  data.vec <- paste0("'quoted", c(" ", "_"), "data'")
  matrix(data.vec, N.rows, N.cols)
}
cache(write.chrmat.vary.rows, atime_write(
  function(N.rows,N.cols=10)chr_mat(N.rows, N.cols),
  "10_chrmat_cols_%s_%d.csv"))
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
aplot(write.chrmat.vary.rows, "Write CSV from matrix with 10 character columns", 1e9, 1e1, "Number of rows", write.colors)
#> Loading required package: directlabels
#> Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
#> logical.return = TRUE, : there is no package called 'directlabels'
#> Warning: Transformation introduced infinite values in continuous y-axis

TODO

facetPlot(write.chrmat.vary.rows)
#> Loading required package: directlabels
#> Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
#> logical.return = TRUE, : there is no package called 'directlabels'
#> Warning: Transformation introduced infinite values in continuous y-axis

TODO

cache(write.chrmat.vary.cols, atime_write(
  function(N.cols, N.rows=10)chr_mat(N.rows, N.cols),
  "10_chrmat_rows_%s_%d.csv"))
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> Warning: Some expressions had a GC in every iteration; so filtering is
#> disabled.
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> x being coerced from class: matrix to data.table
#> Warning: Some expressions had a GC in every iteration; so filtering is
#> disabled.
aplot(write.chrmat.vary.cols, "Write CSV from matrix with 10 character rows", 1e9, 1e1, "Number of columns", write.colors)
#> Loading required package: directlabels
#> Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
#> logical.return = TRUE, : there is no package called 'directlabels'
#> Warning: Transformation introduced infinite values in continuous y-axis

TODO

facetPlot(write.chrmat.vary.cols)
#> Loading required package: directlabels
#> Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
#> logical.return = TRUE, : there is no package called 'directlabels'
#> Warning: Transformation introduced infinite values in continuous y-axis

TODO

Write CSV from character data.table

The code below is for a character data.table with a constant number of columns, and a variable number of rows.

chr_dt <- function(N.rows, N.cols){
  data.table(chr_mat(N.rows, N.cols))
}
cache(write.chr.vary.rows, atime_write(
  function(N.rows,N.cols=10)chr_dt(N.rows, N.cols),
  "10_chr_cols_%s_%d.csv"))
aplot(write.chr.vary.rows, "Write CSV from data.table with 10 character columns", 1e9, 1e1, "Number of rows", write.colors)
#> Loading required package: directlabels
#> Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
#> logical.return = TRUE, : there is no package called 'directlabels'
#> Warning: Transformation introduced infinite values in continuous y-axis

The figure above is useful for comparing different functions, and shows that all have the same asymptotic time complexity class. However, we observe a difference in memory usage: linear for write.csv and constant for others. Below, we draw reference lines, so we can see the complexity class.

facetPlot(write.chr.vary.rows)
#> Loading required package: directlabels
#> Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
#> logical.return = TRUE, : there is no package called 'directlabels'
#> Warning: Transformation introduced infinite values in continuous y-axis

The figure above shows that all functions are linear time, and write.csv is linear memory. The code below is for a character data.frame with a constant number of rows, and a variable number of columns.

cache(write.chr.vary.cols, atime_write(
  function(N.cols, N.rows=10)chr_dt(N.rows, N.cols),
  "10_chr_rows_%s_%d.csv"))
#> Warning: Some expressions had a GC in every iteration; so filtering is
#> disabled.

#> Warning: Some expressions had a GC in every iteration; so filtering is
#> disabled.

#> Warning: Some expressions had a GC in every iteration; so filtering is
#> disabled.
aplot(write.chr.vary.cols, "Write CSV from data.table with 10 character rows", 1e9, 1e1, "Number of columns", write.colors)
#> Loading required package: directlabels
#> Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
#> logical.return = TRUE, : there is no package called 'directlabels'
#> Warning: Transformation introduced infinite values in continuous y-axis

The figure above shows that data.table::fwrite clearly has a smaller slope (linear complexity in number of columns) than the other methods (quadratic complexity), as shown in the plot below, which includes best reference lines above and below each empirical measurement asymptote.

facetPlot(write.chr.vary.cols)
#> Loading required package: directlabels
#> Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
#> logical.return = TRUE, : there is no package called 'directlabels'
#> Warning: Transformation introduced infinite values in continuous y-axis

The comparisons above show significant advantages for data.table for writing CSV data with a large number of columns: asymptotically less time and memory (linear rather than quadratic in number of columns).

Write CSV from data.table with factor columns

The code below is for factor data with a constant number of columns, and a variable number of rows.

fac_dt <- function(N.rows, N.cols){
  data.vec <- factor(paste0("'quoted", c(" ", "_"), "data'"))
  as.data.table(lapply(1:N.cols, function(col.i)rep(data.vec,l=N.rows)))
}
cache(write.fac.vary.rows, atime_write(
  function(N.rows,N.cols=10)fac_dt(N.rows, N.cols),
  "10_fac_cols_%s_%d.csv"))
aplot(write.fac.vary.rows, "Write CSV from data.table with 10 factor columns", 1e9, 1e1, "Number of rows", write.colors)
#> Loading required package: directlabels
#> Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
#> logical.return = TRUE, : there is no package called 'directlabels'
#> Warning: Transformation introduced infinite values in continuous y-axis

TODO. Below, we draw reference lines, so we can see the complexity class.

facetPlot(write.fac.vary.rows)
#> Loading required package: directlabels
#> Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
#> logical.return = TRUE, : there is no package called 'directlabels'
#> Warning: Transformation introduced infinite values in continuous y-axis