tests/FileMatrix,bug20070821.R

library("R.huge")
library("R.utils")

if ("covr" %in% loadedNamespaces())
  options("R.utils::onNonSeekable"="warning")

for (byrow in c(FALSE, TRUE)) {
  pathname <- "example.Rmatrix"
  if (isFile(pathname)) {
    file.remove(pathname)
    if (isFile(pathname))
      stop("File not deleted: ", pathname)
  }

  nrow <- 10
  ncol <- 10
  X <- matrix(0, nrow=nrow, ncol=ncol, byrow=TRUE)
  X[] <- 1:100

  Y <- FileFloatMatrix(pathname, nrow=nrow(X), ncol=ncol(X), byrow=byrow)
  Y[] <- X[]
  stopifnot(identical(X[], Y[]))

  rr <- c(1,3)
  stopifnot(identical(X[rr,], Y[rr,]))

  rr <- 6:2
  cc <- c(1,8,4,2:3)
  X[rr,cc] <- seq_len(length(rr)*length(cc))
  Y[rr,cc] <- X[rr,cc]
  stopifnot(identical(X[], Y[]))

  close(Y)
  rm(Y)
  gc()
}

Try the R.huge package in your browser

Any scripts or data that you put into this service are public.

R.huge documentation built on July 9, 2023, 6:24 p.m.