Read integer values into a standard R vector of integers or alternate containers for large types
read_uint8(con, n = 1, endian = NULL)read_int8(con, n = 1, endian = NULL)
read_int16(con, n = 1, endian = NULL)
read_uint16(con, n = 1, endian = NULL)
read_int32(con, n = 1, endian = NULL)
read_uint32(con, n = 1, endian = NULL, promote = NULL)
read_int64(con, n = 1, endian = NULL, promote = NULL, bounds_check = NULL)
read_uint64(con, n = 1, endian = NULL, promote = NULL, bounds_check = NULL)
Integer data. Usually in standard R integer vector but depending on
the promote
option may be returned in alternate formats
Connection object or raw vector. Connection objects can be
created with file()
, url()
,
rawConnection()
or any of the other many connection creation
functions.
Number of elements to read. Default: 1
Ordering of bytes within the file when reading multi-byte values.
Possible values: 'big' or 'little'.
Default: NULL indicates that
endian option should be retrieved from the connection object if possible
(where the user has used set_endian()
) or otherwise
will be set to "little"
For 'uin32', 'int64' and 'uint64' types, the range of possible
values exceeds R's standard integer type. For these integer types,
values will be promoted to a different container type.
Possible options 'dbl', 'raw', 'hex' and 'bit64'.
Default: NULL indicates that
this option should be retrieved from the connection object if possible
(where the user has used set_integer_promotion()
) or otherwise
will default to "dbl"
.
dbl
Read integer values as double precision floating point. A 'double' will hold integer values (without loss) from -(2^53) up to (2^53). A further warning will be issued if an attempt is made to store an integer value that lies outside this range
hex
Read integers as character vector of hexadecimal strings
raw
Read integer value as a sequence of raw bytes
bit64
Read integer value as a vector of
type bit64::integer64
. This is valid only when reading
'int64' and 'uint64' types
Check values lie within bounds of the given type.
Default: NULL indicates that
this option should be retrieved from the connection object if possible
(where the user has used set_bounds_check()
) or otherwise
will be set to "error"
read_int8()
and read_uint8()
read_int16()
and read_uint16()
read_int32()
and read_uint32()
read_int64()
and read_uint64()
Other data input functions:
read_f64()
,
read_hex()
,
read_raw()
,
read_str()
,
scan_dbl()
# Raw vector with 16 bytes (128 bits) of dummy data
data <- as.raw(c(1:7, 0, 1:8))
con <- rawConnection(data, 'rb')
read_int64(con, n = 1)
read_uint8(con, n = 4)
close(con)
Run the code above in your browser using DataLab