read_elements,BinaryReader,numeric-method | R Documentation |
Read a specified number of elements from a BinaryReader object.
## S4 method for signature 'BinaryReader,numeric'
read_elements(x, num_elements)
x |
Object of class BinaryReader |
num_elements |
Integer specifying number of elements to read |
Numeric vector of read elements
# 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)
close(reader)
# Clean up
unlink(tmp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.