Transfers array data to R and returns it as an R array.
Only in the case of scalars is the result a vector of length 1, as R arrays cannot have 0 axes.
Arguments
- x
(
arrayish)
An array-like object.- check
(
character(1)|FALSE)
How to report a materialized value that the R type cannot hold:"warn"(the default) warns and returns it anyway,"err"aborts, andFALSEskips the scan. Problematic values are the bit-representations reserved for R'sNAvalues, as well as out-of-range values. See the Gotchas article for more.- ...
Passed on to methods.
Value
(array | vector(1))
An R array with the input's shape, or – for a scalar, which R cannot
represent as an array – a vector of length 1.
Details
This is implemented via the generic xlamisc::as_array().
Data types
R has fewer data types than anvl, so the values are converted to the R type that can represent them:
| Data type | R type |
f32, f64 | double |
i8, i16, i32, ui8, ui16 | integer |
i64, ui32, ui64 | bit64::integer64 |
bool | logical |
This has two consequences:
An
f32value is widened to adoubleand keeps the rounding error of the 32-bit float, e.g.as_array(nv_scalar(0.1))is not exactly0.1.Some integer values cannot be represented in R: an
i32ori64value equal to the smallest representable integer is read asNA, and aui64value>= 2^63wraps to a negative number. Thecheckargument decides whether this is reported.
To obtain a different R type, convert the array with nv_convert()
first, or use the coercion functions described in as.double().