Rf_asLogical.Rd
x |
---|
A C int
value.
int asLogical(SEXP x);
In Rinternals.h.
int asLogical(SEXP x) { return asLogical2(x, /* checking = */ 0, R_NilValue, R_NilValue); }
In coerce.c.
# Convert an R length one logical vector to a C int number # Please note that the double backslash in "\n" in Rprintf is only required # because of the inlining of the code here. rlogical_to_cint <- inline::cfunction(c(x = "logical"), ' int x_; x_ = Rf_asLogical(x); Rprintf("x_ is %d\\n", x_); return R_NilValue; ' int x_; x_ = Rf_asLogical(x); Rprintf("x_ is %d\\n", x_); return R_NilValue; ') # NA is mapped to INT_MIN invisible(rlogical_to_cint(NA))#> x_ is -2147483648#> x_ is -2147483648#> x_ is 0#> x_ is 1