Skip to contents

Read a specified number of elements from a BinaryReader object.

Usage

# S4 method for class 'BinaryReader,numeric'
read_elements(x, num_elements)

Arguments

x

Object of class BinaryReader

num_elements

Integer specifying number of elements to read

Value

Numeric vector of read elements

Examples

# \donttest{
# Create a temporary binary file with some test data
tmp <- tempfile()
con <- file(tmp, "wb")
test_data <- rnorm(100)
writeBin(test_data, con, size = 8)
close(con)

# Create reader and read the data
reader <- BinaryReader(tmp, byte_offset = 0L,
                      data_type = "DOUBLE", bytes_per_element = 8L)
data <- read_elements(reader, 100)
#> Warning: incomplete string at end of file has been discarded
close(reader)

# Clean up
unlink(tmp)
# }