readAsRaw {iotools}R Documentation

Read binary data in as raw

Description

readAsRaw takes a connection or file name and reads it into a raw type.

Usage

readAsRaw(con, n, nmax, fileEncoding="")

Arguments

con

A connection object or a character string naming a file from which to save the output.

n

Expected number of bytes to read. Set to 65536L by default when con is a connection, and set to the file size by default when con is a character string.

nmax

Maximum number of bytes to read; missing of Inf to read in the entire connection.

fileEncoding

When con is a connection, the file encoding to use to open the connection.

Value

readAsRaw returns a raw type which can then be consumed by functions like mstrsplit and dstrsplit.

Author(s)

Taylor Arnold

Examples

  mm <- model.matrix(~., iris)
  f <- file("iris_mm.io", "wb")
  writeBin(as.output(mm), f)
  close(f)
  m <- mstrsplit(readAsRaw("iris_mm.io"), type="numeric", nsep="\t")
  head(mm)
  head(m)
  unlink("iris_mm.io")

[Package iotools version 0.3-3 Index]