Rf_ScalarLogical: Rf_ScalarLogical

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 logical vector. The mapping from C integers to R's logical is:

Arguments

x

an int value.

Value

A SEXP object, namely a length one logical vector.

Declaration

1

In Rinternals.h.

Definition

1
2
3
4
5
6
7

In Rinlinedfuns.h.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Convert a C int number as an R length one logical vector with TRUE
true <- inline::cfunction(NULL,
 ' int x = 2;
   SEXP y;
   y = PROTECT(Rf_ScalarLogical(x));
   UNPROTECT(1);
   return y;
 ')
true()

# Convert a C int number as an R length one logical vector with FALSE
false <- inline::cfunction(NULL,
 ' int x = 0;
   SEXP y;
   y = PROTECT(Rf_ScalarLogical(x));
   UNPROTECT(1);
   return y;
 ')
false()

# Convert a C int number as an R length one logical vector with NA
na_logical <- inline::cfunction(NULL,
 ' int x = NA_LOGICAL;
   SEXP y;
   y = PROTECT(Rf_ScalarLogical(x));
   UNPROTECT(1);
   return y;
 ')
na_logical()

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