search for: aslength

Displaying 2 results from an estimated 2 matches for "aslength".

Did you mean: tslength
2015 Sep 20
2
Long vectors: Missing values and R_xlen_t?
Is there a missing value constant defined for R_xlen_t, cf. NA_INTEGER (== R_NaInt == INT_MIN) for int(eger)? If not, is it correct to assume that missing values should be taken care/tested for before coercing from int or double? Thank you, Henrik
2015 Sep 21
0
Long vectors: Missing values and R_xlen_t?
...stored in R_xlen_t even for indexing. --- cut here, content below is less relevant --- That said, when converting packages from "legacy" .Call code before long vector support which used asInteger() to convert an index I tend to use this utility for convenience: static R_INLINE R_xlen_t asLength(SEXP x, R_xlen_t NA) { double d; if (TYPEOF(x) == INTSXP && LENGTH(x) > 0) { int res = INTEGER(x)[0]; return (res == NA_INTEGER) ? NA : ((R_xlen_t) res); } d = asReal(x); return (R_finite(d)) ? ((R_xlen_t) d) : NA; } Note that this explicitly allows t...