write_elements | R Documentation |
Write a sequence of elements from an input source
write_elements(x, els)
x |
the output channel |
els |
the elements to write |
Invisibly returns NULL
after writing the elements.
# Create a temporary binary file for writing
tmp <- tempfile()
writer <- BinaryWriter(tmp, byte_offset = 0L,
data_type = "DOUBLE", bytes_per_element = 8L)
# Write some random data
data <- rnorm(100)
write_elements(writer, data)
close(writer)
# Read back the data to verify
reader <- BinaryReader(tmp, byte_offset = 0L,
data_type = "double", bytes_per_element = 8L)
read_data <- read_elements(reader, 100)
close(reader)
# Verify data was written correctly
all.equal(data, read_data)
# Clean up
unlink(tmp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.