View source: R/connection-config.R
set_integer_promotion | R Documentation |
Tag a connection with the preferred integer promotion method for types larger that R's integer type i.e. uint32, uint64, int64
set_integer_promotion(con, uint32 = "dbl", int64 = "dbl", uint64 = "dbl")
con |
Connection object or raw vector. Connection objects can be
created with |
uint32 , int64 , uint64 |
specifiy separate promotion methods for these types
One of: 'dbl', 'hex', 'raw' and 'bit64' (for 64-bit types only) Default: 'dbl'.
This default may be over-ridden by specifying
the
|
Modified connection object
Other connection configuration functions:
set_bounds_check()
,
set_endian()
,
set_eof_check()
,
set_na_check()
# Open a connection and configure it so all 'uint32' values are
# read as floating point and all all 'uint64' values are read as hexadecimal strings
con <- rawConnection(as.raw(c(1:7, 0, 1:7, 0, 1:7, 0, 1:7, 0)), "rb")
con <- set_integer_promotion(con, uint32 = "dbl", uint64 = "hex")
# Future reads of uint64 will return hex strings
read_uint64(con, n = 2)
# Unless over-ridden during the read
read_uint64(con, n = 1, promote = "dbl")
close(con)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.