BinaryReader: Create Binary Reader Object

View source: R/binary_io.R

BinaryReaderR Documentation

Create Binary Reader Object

Description

Create a new instance of the BinaryReader class for reading bulk binary data.

Usage

BinaryReader(
  input,
  byte_offset,
  data_type,
  bytes_per_element,
  endian = .Platform$endian,
  signed = TRUE
)

Arguments

input

Character string (file name) or connection object to read from

byte_offset

Integer specifying bytes to skip at start of input

data_type

Character string specifying R data type ('integer', 'double', etc.)

bytes_per_element

Integer specifying bytes per data element (e.g., 4 or 8)

endian

Character string specifying endianness ('big' or 'little', default: platform-specific)

signed

Logical indicating if data type is signed (default: TRUE)

Value

An object of class BinaryReader

See Also

BinaryWriter for writing binary data

Examples

## Not run: 
# Create reader for double-precision data
reader <- BinaryReader("data.bin", byte_offset = 0L,
                      data_type = "double", bytes_per_element = 8L)
                      
# Read from existing connection with offset
con <- file("data.bin", "rb")
reader <- BinaryReader(con, byte_offset = 100L,
                      data_type = "integer", bytes_per_element = 4L)

## End(Not run)

bbuchsbaum/neuroim2 documentation built on Jan. 2, 2025, 3:38 p.m.