Description Arguments Value Declaration Definition Examples
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.
1 | SEXP Rf_ScalarInteger(int x);
|
In Rinternals.h.
1 2 3 4 5 6 | INLINE_FUN SEXP ScalarInteger(int x)
{
SEXP ans = allocVector(INTSXP, 1);
SET_SCALAR_IVAL(ans, x);
return ans;
}
|
In Rinlinedfuns.h.
1 2 3 4 5 6 7 8 9 | # 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;
')
forty_two()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.