Rf_ScalarInteger: Rf_ScalarInteger

Description Arguments Value Declaration Definition Examples

Description

\Sexpr[results=rd, stage=render]{c3po:::badge('fnp')} \Sexpr[results=rd, stage=render]{c3po:::badge('c2r')} \Sexpr[results=rd, stage=render]{c3po:::badge('prot')}

Converts an int x to a SEXP object that represents an R length one integer vector.

Arguments

x

an int value.

Value

A SEXP object, namely a length one integer vector.

Declaration

1

In Rinternals.h.

Definition

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.

Examples

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()

ramiromagno/c3po documentation built on Jan. 5, 2021, 8:01 p.m.