Rf_ScalarInteger.Rd
Converts an int x
to a SEXP object that represents an R length one
integer
vector.
x | an int value. |
---|
A SEXP object, namely a length one integer
vector.
SEXP Rf_ScalarInteger(int x);
In Rinternals.h.
INLINE_FUN SEXP ScalarInteger(int x) { SEXP ans = allocVector(INTSXP, 1); SET_SCALAR_IVAL(ans, x); return ans; }
In Rinlinedfuns.h.
# Convert a C int number as an R length one integer vector forty_two <- inline::cfunction(NULL, ' int x = 42; SEXP y; y = PROTECT(Rf_ScalarInteger(x)); UNPROTECT(1); return y; ' int x = 42; SEXP y; y = PROTECT(Rf_ScalarInteger(x)); UNPROTECT(1); return y; ') forty_two()#> [1] 42