Function, pure C to R Needs PROTECT()

Converts a double x to a SEXP object that represents an R length one numeric vector.

Arguments

x

a double

Value

A SEXP object, namely a length one numeric vector.

Declaration

SEXP Rf_ScalarReal(double x);

In Rinternals.h.

Examples

# Convert a C double number as an R length one numeric vector forty_two <- inline::cfunction(NULL, ' double x = 42.; SEXP y; y = PROTECT(Rf_ScalarReal(x)); UNPROTECT(1); return y; ' double x = 42.; SEXP y; y = PROTECT(Rf_ScalarReal(x)); UNPROTECT(1); return y; ') forty_two()
#> [1] 42