Learn R Programming

ctypesio (version 0.1.2)

set_endian: Tag a connection with the preferred endianness

Description

Tag a connection with the preferred endianness

Usage

set_endian(con, endian = "little")

Value

Modified connection object

Arguments

con

Connection object or raw vector. Connection objects can be created with file(), url(), rawConnection() or any of the other many connection creation functions.

endian

Default endianness to assign to this connection. One of either "little" or "big". Default: "little". This default may be over-ridden by specifying the endian argument when calling individual functions.

See Also

Other connection configuration functions: set_bounds_check(), set_eof_check(), set_integer_promotion(), set_na_check()

Examples

Run this code
# Open a connection and configure it so all subsequent read/write operations
# use big-endian ordering.
con <- rawConnection(as.raw(c(0, 1, 0, 1)), "rb")
con <- set_endian(con, endian = "big")

# Future reads will be be big endian
read_uint16(con, n = 1)

# Unless over-ridden during the read
read_uint16(con, n = 1, endian = "little")

close(con)

Run the code above in your browser using DataLab