# 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