BinaryWriter: Create Binary Writer Object

View source: R/binary_io.R

BinaryWriterR Documentation

Create Binary Writer Object

Description

Create a new instance of the BinaryWriter class for writing bulk binary data.

Usage

BinaryWriter(
  output,
  byte_offset,
  data_type,
  bytes_per_element,
  endian = .Platform$endian
)

Arguments

output

Character string (file name) or connection object to write to

byte_offset

Integer specifying bytes to skip at start of output

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)

Value

An object of class BinaryWriter

See Also

BinaryReader for reading binary data

Examples

## Not run: 
# Create writer for double-precision data
writer <- BinaryWriter("output.bin", byte_offset = 0L,
                      data_type = "double", bytes_per_element = 8L)
                      
# Write to existing connection with offset
con <- file("output.bin", "wb")
writer <- BinaryWriter(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.