R API documentation

Next:   [Index]

Introduction

This unofficial, incomplete, perpetually lagging behind, and subtly wrong document attempts to document the surface of the C API of the R programming language in the style of Unix man pages or the Rd help system.

© 2024 Ivan Krylov, Erez Shomron

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved an author.

In preparation of this work, the authors read the R source code (© R Core Team, GPL ≥ 2), R header files (LGPL ≥ 2.1), and manuals such as “Writing R Extensions” and “R Internals” (Latex2e-translated-notice).


Next: , Previous: , Up: Introduction   [Index]

1 Types


Next: , Up: Types   [Index]

SEXP

#include <Rinternals.h>
typedef struct SEXPREC * SEXP;

This is a pointer to an incomplete type that represents a single value in R. It is almost never correct to give a null SEXP to R (some clearly marked ALTREP methods are allowed to return a null SEXP). With only two exceptions (see tryEval), R will never return a null SEXP1.


Next: , Previous: , Up: Types   [Index]

R_xlen_t

#include <Rinternals.h>
typedef /*...*/ R_xlen_t;
#define R_XLEN_T_MAX /*...*/
#define R_PRIdXLEN_T /*...*/

A signed integer type that represents lengths of R vectors. Will likely be larger than a plain int on 64-bit platforms. (Note that long is 32-bit on 64-bit Windows!)

In practice, all feasible values of this type can be safely represented inside of a double value, and R_XLEN_T_MAX places an appropriate upper limit.

Use R_PRIdXLEN_T as an appropriate printf specifier to print values of type R_xlen_t on R ≥ 4.4:

Rprintf("%" R_PRIdXLEN_T "\n", XLENGTH(value));

Versions: Long vector support appeared in version 3.0.0.


Next: , Previous: , Up: Types   [Index]

R_len_t

#include <Rinternals.h>
typedef int R_len_t;
#define R_LEN_T_MAX INT_MAX

A signed integer type that represents lengths of “standard” (that is, non-long) R vectors. In most places, R_xlen_t should be used instead.


Next: , Previous: , Up: Types   [Index]

Rboolean

#include <R_ext/Boolean.h>
typedef /*...*/ Rboolean;
enum { FALSE=0, TRUE };

A C type with enumeration constants FALSE and TRUE defined.


Next: , Previous: , Up: Types   [Index]

DL_FUNC

#include <R_ext/Rdynload.h>
typedef /*...*/ (*DL_FUNC)(/*...*/);

The type used to pass around function pointers. Casts to and from DL_FUNC are required to avoid diagnostic messages from the compiler; the true type of the function must be known separately.


Next: , Previous: , Up: Types   [Index]

PROTECT_INDEX

#include <Rinternals.h>
typedef /*...*/ PROTECT_INDEX;

A C integer type used to represent positions on the internal pointer protection stack. See PROTECT_WITH_INDEX.


Next: , Previous: , Up: Types   [Index]

SEXPTYPE

#include <Rinternals.h>
typedef /*...*/ SEXPTYPE;

A C integer type that identifies the type of an R value. See Writing R Extensions, section 5.9.3 “Details of R types” for more information.

TypeNameMeaning
NILSXPNULLThe R NULL value. See R_NilValue for the pre-existing object.
SYMSXPsymbol
name
Symbols are used for names of R objects. They are persistent (never garbage-collected); each contains a string in the native encoding. See install for creation of new symbols.
LISTSXPpairlistLisp-style pairlists consist of “CONS cells”, each containing two arbitrary R objects (CAR and CDR) and an optional TAG, which must be a symbol. Typically, CAR represents the current element in the list while CDR points at the next cell in the list. See CONS and allocVector for creation of new pairlists.
CLOSXPclosureA normal R function, consists of “formals” (its arguments), body (the code of the function) and environment (where the variables are looked up if not present in the calling frame). See R_mkClosure for creation of new closures.
ENVSXPenvironmentEnvironments contain variables and reference parent environments. See R_NewEnv for creation of new environments.
PROMSXPpromisePromises are an implementation detail of R’s lazy evaluation.
LANGSXPlanguageLike LISTSXP above, but used to express language constructs, such as function calls. See LCONS and allocVector for creation of new call objects.
SPECIALSXP
BUILTINSXP
special
builtin
.Internal and .Primitive R functions, respectively.
CHARSXPcharInternal type used for individual elements of character vectors. See mkChar for creation of new strings.
LGLSXPlogicallogical() vectors in R, individual elements represented by ints. See allocVector or ScalarLogical.
INTSXPintegerinteger() vectors in R, individual elements represented by ints. See allocVector or ScalarInteger.
REALSXPdouble
numeric
numeric() vectors in R, individual elements represented by doubles. See allocVector or ScalarReal.
CPLXSXPcomplexcomplex() vectors in R, individual elements of type Rcomplex. See allocVector or ScalarComplex.
STRSXPcharactercharacter() vectors in R, individual elements are SEXPs of type CHARSXP (see above). See allocVector or mkString or ScalarString.
DOTSXP...Internal object used to represent the function arguments contained inside ... during a function call.
VECSXPlist“Generic vectors” (list()) in R. Individual elements are arbitrary SEXPs. See allocVector.
EXPRSXPexpressionexpression() vectors in R, indended for storage of LANGSXP objects. Very similar to VECSXP lists. See allocVector.
BCODESXPbytecodeFunction bytecode.
EXTPTRSXPexternalptrAn R object wrapping an arbitrary data or function pointer, can have a finalizer attached. See R_MakeExternalPtr.
WEAKREFSXPweakrefA weak reference to another reference-semantics R object, can have a finalizer attached. See R_MakeWeakRef.
RAWSXPrawraw() vectors in R, intended for storage of arbitrary bytes. See allocVector or ScalarRaw.
OBJSXP
S4SXP
object
S4
Formal objects that don’t inherit from a different base type. See allocS4Object, an experimental interface.
The name S4SXP has been deprecated (but not removed) in version 4.4, introducing OBJSXP instead.
ANYSXPanyUsed internally to denote a function accepting any R value as an argument.

In general, behaviour is undefined if using a SEXPTYPE that is not one of the constants mentioned above.


Next: , Previous: , Up: Types   [Index]

R_SIZE_T

#include <R_ext/Utils.h>
#define R_SIZE_T /*...*/

A C preprocessor definition that expands to either size_t in C or std::size_t in C++. The header includes either stddef.h or cstddef to provide the actual type definition.


Next: , Previous: , Up: Types   [Index]

cetype_t

#include <Rinternals.h>
typedef enum {
 CE_NATIVE = /*...*/,
 CE_UTF8   = /*...*/,
 CE_LATIN1 = /*...*/,
 CE_BYTES  = /*...*/,
 CE_SYMBOL = /*...*/,
 CE_ANY    = /*...*/,
} cetype_t;

A set of C enumeration constants defining character encoding codes for use in strings:

CE_NATIVE

The encoding defined by the current locale. Will correspond to UTF-8 on most modern systems, but may refer to the ANSI code page on older versions of Windows, or something completely different, such as ISO-8859-15 (Latin-9) or KOI8-R, on other Unix-like systems.

CE_UTF8

The multi-byte Unicode encoding used by most systems at the time of writing.

CE_LATIN1

Latin-1 is also known as ISO-8859-1, the ISO/IEC 8859 character encoding designed for use in Western Europe.

CE_BYTES

Used to mark a string as containing bytes in an unknown encoding so that it will not be translated. The zero byte still terminates a string, so having it in the middle of one is not allowed.

CE_SYMBOL

Used internally to indicate the Adobe Symbol encoding.

CE_ANY

Used internally to indicate that the string will not need re-encoding.


Previous: , Up: Types   [Index]

Rbyte

#include <Rinternals.h>
typedef unsigned char Rbyte;

The type used by R to represent arbitrary bytes.


Next: , Previous: , Up: Introduction   [Index]

2 Constants


Next: , Up: Constants   [Index]

R_NilValue

#include <Rinternals.h>
LibExtern SEXP R_NilValue;

The NULL R value, of type NILSXP. No other values of this type need to be created. This is the representation of an empty pairlist.


Next: , Previous: , Up: Constants   [Index]

R_NamesSymbol

#include <Rinternals.h>
LibExtern SEXP R_DimNamesSymbol;
LibExtern SEXP R_NamesSymbol;

The pre-installed symbols for attribute names (see setAttrib) names and dimnames.


Next: , Previous: , Up: Constants   [Index]

R_PosInf

#include <R_ext/Arith.h>
/* alternatively: */
#include <Rmath.h>

extern double R_PosInf;
extern double R_NegInf;
#define NA_REAL /*...*/

These variables contain the special floating-point values.

The positive infinity is larger than all values except itself and NaN, and the negative infinity is lower than all values except itself and NaN.

NA_REAL is a NaN value with a payload that identifies it as a missing value (see ISNAN).


Next: , Previous: , Up: Constants   [Index]

M_PI

#include <R_ext/Constants.h>
#ifndef M_PI
#define M_PI /*...*/
#endif

#include <Rmath.h>
#ifndef M_PI
#define M_PI /*...*/
#endif
#ifndef M_E
#define M_E /*...*/
#endif

These preprocessor constants define the π number and the Euler’s constant e.


Next: , Previous: , Up: Constants   [Index]

R_INLINE

#include <Rconfig.h>
#define R_INLINE /*...*/

This preprocessor constant expands to the inline keyword suitable for the C compiler, or to nothing if no such keyword was found during the R configuration.


Previous: , Up: Constants   [Index]

R_Version

#include <Rversion.h>
#define R_Version(v, p, s) /*...*/
#define R_VERSION /*...*/

#define R_MAJOR /*...*/
#define R_MINOR /*...*/

#define R_YEAR /*...*/
#define R_MONTH /*...*/
#define R_DAY /*...*/

Arguments

v

The major version number, “4” in “4.5.0”.

p

The minor version number, “5” in “4.5.0”.

s

The “patch” version number, “0” in “4.5.0”.

Value and side effects

R_Version
R_VERSION

A call to the R_Version(v, p, s) macro expands to a numeric expression the value of which is comparable to the pre-defined integer constant R_VERSION. It is intended for use with integer constants in preprocessor tests:

#if R_VERSION >= R_Version(3, 3, 0)
/* Can use features from R-3.3.0 */
#endif
R_MAJOR

Expands to a string literal containing the current major version of R.

R_MINOR

Expands to a string literal containing the current minor and patch versions of R separated by a dot: "p.s".

R_YEAR
R_MONTH
R_DAY

These macros expand to string literals containing the release date of the current version of R.


Next: , Previous: , Up: Introduction   [Index]

3 Functions


Next: , Up: Functions   [Index]

XLENGTH

#include <Rinternals.h>
R_xlen_t XLENGTH(SEXP x);
R_xlen_t Rf_xlength(SEXP x);
#ifndef R_NO_REMAP
#define xlength Rf_xlength
#endif
int LENGTH(SEXP x);
R_len_t Rf_length(SEXP x);
#ifndef R_NO_REMAP
#define length Rf_length
#endif

Arguments

x

An R value of a vector type: CHARSXP, LGLSXP, INTSXP, REALSXP, CPLXSXP, STRSXP, VECSXP, EXPRSXP, RAWSXP.

For Rf_xlength, also allowed are NILSXP, LISTSXP, LANGSXP, DOTSXP, and ENVSXP, and all other types.

Value and side effects

XLENGTH
Rf_xlength

Returns the number of elements in the vector. Rf_xlength will also return 0 for a NILSXP; the number of elements in a pairlist type (LISTSXP, LANGSXP, DOTSXP); the number of elements in an environment (ENVSXP). For a CHARSXP, the length of the string, not including the terminating zero byte. Behaviour is unspecified for XLENGTH if x is not of a vector type. Rf_xlength returns 1 for all other types.

Versions: This function appeared in version 3.0.0.

LENGTH
Rf_length

Same as Rf_xlength, but raises an error if the length is not representable as an R_len_t / int.


Next: , Previous: , Up: Functions   [Index]

PrintValue

#include <Rinternals.h>
void Rf_PrintValue(SEXP s);
#ifndef R_NO_REMAP
#define PrintValue Rf_PrintValue
#endif

Not declared in a public header, for use in a debugger:

void R_PV(SEXP s);

Arguments

s

An arbitrary R object to be printed. For R_PV, must have the class attribute set.

Value and side effects

Prints a representation of s on R’s standard output using the global printing options.


Next: , Previous: , Up: Functions   [Index]

R_registerRoutines

#include <R_ext/Rdynload.h>
int R_registerRoutines(
 DllInfo *info,
 const R_CMethodDef * const croutines,
 const R_CallMethodDef * const callRoutines,
 const R_FortranMethodDef * const fortranRoutines,
 const R_ExternalMethodDef * const externalRoutines
);
Rboolean R_useDynamicSymbols(
 DllInfo *info, Rboolean use_symbols
);
Rboolean R_forceSymbols(
 DllInfo *info, Rboolean force_symbols
);
DL_FUNC R_FindSymbol(
 char const * name, char const * pkg,
 R_RegisteredNativeSymbol * symbol
);

Arguments

info

An opaque pointer passed by R to the initialization routine of the package.

croutines

An array of structs describing the native functions for use with .C in the R code, containing the following fields:

const char *name

The R-visible name of the function.

DL_FUNC fun

The pointer to the function. The function is not required to conform to the DL_FUNC prototype; R will cast the pointer back as appropriate according to the value of numArgs.

int numArgs

The number of arguments accepted by the function.

R_NativePrimitiveArgType *types

Optional. If specified, must be an array of numArgs values containing one of the SEXPTYPE constants, SINGLESXP (for single-precision floats), or ANYSXP (meaning “any otherwise supported argument”). Passing a NILSXP to .C functions is not allowed; passing of LISTSXP lists is deprecated.

The array must be terminated by {NULL, NULL, 0, NULL}.

Versions: Prior to version 3.4.0, the struct contained a nullable field, R_NativeArgStyle *styles, which was intended to specify whether an argument was for input, output, or something else.

callRoutines

An array of descriptions of native functions for use with .Call in the R code. The structure fields are as follows:

const char *name

The R-visible name of the function.

DL_FUNC fun

The pointer to the function. R will cast the pointer as appropriate according to the value of numArgs.

int numArgs

The number of arguments accepted by the function.

Must be terminated by {NULL, NULL, 0}.

fortranRoutines

An array of descriptions of native functions for use with .Fortran in the R code. The structure fields are the same as in croutines.

There are portability problems associated with passing STRSXPs to .Fortran code: only the first element of the vector will be passed. Passing VECSXP or LISTSXP lists, NILSXP, functions, and environments is not allowed.

externalRoutines

An array of descriptions of native functions for use with .External in the R code. The structure fields are the same as in callRoutines.

use_symbols

If FALSE, will disable the lookup of package functions by their linker-level names and will only allow calling registered functions from the package shared library, but R code will still be able to specify the registered name as a string.

force_symbols

If TRUE, will only allow to call the native routines from this shared library using special objects provided by useDynLib(.registration = TRUE), not by their names.

name

The name of a native function registered by a package using R_registerRoutines or exported by its shared object, a 0-terminated C string in the native encoding.

pkg

The name of the package to look up the function in, a 0-terminated C string in the native encoding. Can be an empty string to mean all shared objects loaded by R.

symbol

Pointer to an opaque structure used internally. Must be a null pointer.

Value and side effects

R_registerRoutines

Registers the native functions for use with R. May raise R-level errors.

R_useDynamicSymbols
R_forceSymbols

Sets function resolution options, returning the previous value of the setting.

R_FindSymbol

Looks up and returns the address of a symbol specified by name in shared objects loaded by R and specified by pkg. For shared objects where useDynamicLookup is set to FALSE, only the registered symbols are searched and no dynamic lookup is performed. For shared objects where forceSymbols is set to TRUE, the lookup is not performed at all.

See Writing R Extensions, section 5.4 “Registering native routines” for more information.


Next: , Previous: , Up: Functions   [Index]

R_RegisterCCallable

#include <R_ext/Rdynload.h>
void R_RegisterCCallable(
 const char *package, const char *name, DL_FUNC fptr
);
DL_FUNC R_GetCCallable(
 const char *package, const char *name
);

Arguments

package

The name of the package that owns the function.

name

The string identifying the function within the package.

fptr

The function pointer to be stored by R_RegisterCCallable and returned by R_GetCCallable. The function doesn’t have to conform to the DL_FUNC prototype; it is expected that the pointer will be cast to some other function type.

Value and side effects

R_RegisterCCallable

Associates fptr with the two strings package and name.

R_GetCCallable

Returns the fptr from the previously established association or raises an error.

The package that calls R_GetCCallable must specify the owner of the callable in both LinkingTo and either Imports or Depends of its DESCRIPTION. Great care must be taken to ensure that the interface of the callable matches the expectations of the caller.

See Writing R Extensions, section 5.4.3 “Linking to native routines in other packages” for more information.

Versions: Both functions first introduced in version 2.4.0.


PROTECT

#include <Rinternals.h>

SEXP Rf_protect(SEXP x);
#ifndef R_NO_REMAP
#define protect Rf_protect
#endif
#define PROTECT(x) Rf_protect(x)

void Rf_unprotect(int n);
#ifndef R_NO_REMAP
#define unprotect Rf_unprotect
#endif
#define UNPROTECT(n) Rf_unprotect(n)

Arguments

x

An arbitrary R value.

n

The number of R values to remove from the pointer protection stack.

Value and side effects

Rf_protect

Puts the x on the internal pointer protection stack so that it won’t be deallocated by the garbage collector. Any values referenced by x are also protected. Raises an error if the (limited-size) stack is full. Returns the same x, making it possible to use the idiom SEXP val = PROTECT(get_val());.

Unlike almost all of R API, PROTECT will not invoke the garbage collector while running.

Rf_unprotect

Removes the last n elements from the pointer protection stack. The package code must leave the pointer protection stack in the same state as it was on function entry.

Almost all R functions can invoke the garbage collector, so any value that may be used later in a function must be protected before calling R API. It’s best to write functions that only protect a constant number of elements regardless of the size of the input.


Next: , Previous: , Up: Functions   [Index]

PROTECT_WITH_INDEX

#include <Rinternals.h>
void R_ProtectWithIndex(
 SEXP value, PROTECT_INDEX * index
);
#define PROTECT_WITH_INDEX(value, index) R_ProtectWithIndex(value, index)
void R_Reprotect(
 SEXP value, PROTECT_INDEX index
);
#define REPROTECT(value, index) R_Reprotect(value, index)

Arguments

value

An arbitrary R value.

index

The index identifying the position of value on the pointer protection stack.

Value and side effects

R_ProtectWithIndex

Protects (see PROTECT) the value and returns the protection index in the output variable index.

R_Reprotect

Puts the given value at position index in the pointer protection stack, replacing the one previously referenced there.

Unlike almost all of R API, these two functions are guaranteed not to invoke the garbage collector while running.


Next: , Previous: , Up: Functions   [Index]

R_PreserveInMSet

#include <Rinternals.h>
SEXP R_NewPreciousMSet(int n);
void R_PreserveInMSet(
 SEXP x, SEXP mset
);
void R_ReleaseFromMSet(
 SEXP x, SEXP mset
);

Arguments

n

The initial size of the precious multi-set.

x

An arbitrary R value.

mset

A precious multi-set previously returned by R_NewPreciousMSet.

The precious multi-set is introduced to make it possible to protect values and then unprotect them by value (as opposed to unprotecting by index in the protection stack), even if a single value has been protected more than once. The need for this reportedly arises in generated parser code (such as bison/yacc).

Value and side effects

R_NewPreciousMSet

Returns a newly allocated precious multi-set. Its SEXPTYPE is unspecified; it should only be used with functions described here. Like other R values, it must be protected and will protect values placed inside it.

R_PreserveInMSet

Adds the value into mset, resizing it as needed. The allocation may fail and raise an error.

R_ReleaseFromMSet

Decrements the count of value in mset. This will unprotect value if the count reaches 0 and it’s not referenced in a different protected value.

Versions: These functions appeared in version 3.6.0.


Next: , Previous: , Up: Functions   [Index]

UNPROTECT_PTR

#include <Rinternals.h>
void Rf_unprotect_ptr(SEXP x);
#ifndef R_NO_REMAP
#define unprotect_ptr Rf_unprotect_ptr
#endif
#define UNPROTECT_PTR(x) Rf_unprotect_ptr(x)

Arguments

x

An arbitrary R value.

Value and side effects

Locates x on the protection stack and unprotects it.

This function is dangerous and may result in unexpected protection stack layout and hard-to-debug issues if x is protected multiple times. See also: https://blog.r-project.org/2018/12/10/unprotecting-by-value/index.html.


Next: , Previous: , Up: Functions   [Index]

R_PreserveObject

#include <Rinternals.h>
void R_PreserveObject(SEXP x);
void R_ReleaseObject(SEXP x);

Arguments

x

An arbitrary R value.

Value and side effects

R_PreserveObject

Puts x into the persistent list of objects that should not be garbage-collected. This list persists for the duration of the R session.

R_ReleaseObject

Removes x from the persistent list of protected objects.


Next: , Previous: , Up: Functions   [Index]

allocVector

#include <Rinternals.h>
SEXP Rf_allocVector(
 SEXPTYPE type, R_xlen_t length
);
#ifndef R_NO_REMAP
#define allocVector Rf_allocVector
#endif
SEXP Rf_alloc3DArray(
 SEXPTYPE type,
 int dim1, int dim2, int dim3
);
#ifndef R_NO_REMAP
#define alloc3DArray Rf_alloc3DArray
#endif
SEXP Rf_allocArray(
 SEXPTYPE type,
 SEXP dim
);
#ifndef R_NO_REMAP
#define allocArray Rf_allocArray
#endif
SEXP Rf_allocMatrix(
 SEXPTYPE type,
 int nrows, int ncols
);
#ifndef R_NO_REMAP
#define allocMatrix Rf_allocMatrix
#endif

Arguments

type

The type of the vector to allocate (see SEXPTYPE): must be any of the vector types (CHARSXP, LGLSXP, INTSXP, REALSXP, CPLXSXP, STRSXP, VECSXP, EXPRSXP, RAWSXP), or the pairlist types (LISTSXP, LANGSXP).

length

The length of the vector-to-be.

dim1, dim2, dim3

The desired dimensions of the array (as in c(dim1, dim2, dim3)). Their product must not overflow R_xlen_t.

dim

The desired dim attribute provided as an already existing R vector dim of type INTSXP. prod(dim) must not overflow R_xlen_t.

nrows, ncols

The desired dimensions of the matrix to allocate.

Value and side effects

Rf_allocVector

Allocates and returns a vector of the specified type and length. Signals an R-level error if an allocation fails or if length exceeds an internal limit.

Here and below, the the contents of the freshly-allocated vector depends on its type. Contents of atomic vectors (REALSXP, INTSXP, LGLSXP, CPLXSXP, RAWSXP) will be undefined and must be initialised before any other use. EXPRSXP and VECSXP vectors will consist of R_NilValue elements. An STRSXP vector will consist of blank strings. See allocList for pairlists.

Rf_alloc3DArray

Versions: Appeared in 2.6.0.

Rf_allocArray

Allocates and returns an array of the specified type with the specified dimensions (either dim or c(dim1, dim2, dim3)). The dim value becomes shared with the returned value.

If prod(dim) or the product of dim1, dim2, dim3 overflows R_xlen_t, behaviour is undefined2.

Rf_allocMatrix

A matrix of the specified type and dimensions (c(nrows, ncols)).


Next: , Previous: , Up: Functions   [Index]

xlengthgets

#include <Rinternals.h>
SEXP Rf_lengthgets(
 SEXP x, R_len_t n
);
#ifndef R_NO_REMAP
#define lengthgets Rf_lengthgets
#endif
SEXP Rf_xlengthgets(
 SEXP x, R_xlen_t n
);
#ifndef R_NO_REMAP
#define xlengthgets Rf_xlengthgets
#endif

Arguments

x

An R value of a vector type: CHARSXP, LGLSXP, INTSXP, REALSXP, CPLXSXP, STRSXP, VECSXP, EXPRSXP, RAWSXP.

n

The desired length of the vector.

Value and side effects

Returns the equivalent of length(x) <- n in R, which may reuse the memory of the original x, or may be allocated anew.

The usual protection rules apply: after the call to xlengthgets, the return value must be protected in place of x (see PROTECT_WITH_INDEX).


Next: , Previous: , Up: Functions   [Index]

R_alloc

#include <R_ext/Memory.h>
char * R_alloc(
 R_SIZE_T n, int size
);
long double * R_allocLD(size_t n);
void* vmaxget(void);
void vmaxset(const void * vmax);

char * S_alloc(long n, int size);
char * S_realloc(
 char * p, long n, long old, int size
);

Arguments

n

The number of elements to allocate the buffer for.

size

The size of individual element comprising the buffer to allocate.

vmax

The opaque context pointer previously returned by vmaxget.

p

A pointer previously returned by S_alloc.

Value and side effects

R_alloc

Allocates a buffer for n contiguous elements, each of size size, overflow-safe, with the typical malloc guarantees about alignment, and returns a pointer to it. An error is raised on any failures. The memory is managed by R and will be released automatically on return from a call to .C(...) / .Call(...) / .External(...).

R_allocLD

Allocates an appropriately aligned buffer of long double[n] in a similar manner and returns a pointer to it.

Versions: This function has been introduced in version 3.2.0.

vmaxget

Returns the context pointer indicating the currently protected allocations previously made by R_alloc or R_allocLD or other R functions that use these two internally.

vmaxset

Restores the context pointer, unprotecting all the allocations made since the corresponding call to vmaxget.

S_alloc

Like R_alloc, but the returned buffer is zeroed out. Not recommended for general use because the number of elements n is only of type long, which may be much smaller than size_t.

S_realloc

Like S_alloc, but the first old elements of the buffer are copied from p. The allocation in p is otherwise untouched and remains valid. If old * size overflows size_t, behaviour is undefined.


Next: , Previous: , Up: Functions   [Index]

copyVector

#include <Rinternals.h>
void Rf_copyVector(
 SEXP destination, SEXP source
);
#ifndef R_NO_REMAP
#define copyVector Rf_copyVector
#endif
void Rf_copyMatrix(
 SEXP destination, SEXP source, Rboolean byrow
);
#ifndef R_NO_REMAP
#define copyMatrix Rf_copyMatrix
#endif

Arguments

destination
source

R values of the same vector type, one of STRSXP, LGLSXP, INTSXP, REALSXP, CPLXSXP, EXPRSXP, VECSXP, RAWSXP, but not necessarily same length. For copyMatrix, destination must be a matrix.

byrow

If TRUE, fill destination with elements row by row, like matrix(byrow = TRUE) in R. Otherwise fill it column by column, as in copyVector.

Value and side effects

Rf_copyVector

Copies the contents of source into target, filling the entire xlength(target), recycling the elements of source if necessary.

Rf_copyMatrix

Like copyVector, but makes it possible to fill a matrix row by row from a vector.


Next: , Previous: , Up: Functions   [Index]

copyMostAttrib

#include <Rinternals.h>
void Rf_copyMostAttrib(
 SEXP source, SEXP destination
);
#ifndef R_NO_REMAP
#define copyMostAttrib Rf_copyMostAttrib
#endif

Arguments

source

An arbitrary R value to take the attributes from.

destination

An arbitrary R value (except NULL, which doesn’t have attributes) to set the attributes on.

Value and side effects

destination takes on the values of every attribute of source except names, dim, dimnames, sharing them with source without duplication.

Sets the object bit on destination if it was set on source; sets the S4 object bit on destination to the value it had on source.


Next: , Previous: , Up: Functions   [Index]

isReal

#include <Rinternals.h>
Rboolean Rf_isComplex(SEXP value);
#ifndef R_NO_REMAP
#define isComplex Rf_isComplex
#endif
Rboolean Rf_isEnvironment(SEXP value);
#ifndef R_NO_REMAP
#define isEnvironment Rf_isEnvironment
#endif
Rboolean Rf_isExpression(SEXP value);
#ifndef R_NO_REMAP
#define isExpression Rf_isExpression
#endif
Rboolean Rf_isFunction(SEXP value);
#ifndef R_NO_REMAP
#define isFunction Rf_isFunction
#endif
Rboolean Rf_isInteger(SEXP value);
#ifndef R_NO_REMAP
#define isInteger Rf_isInteger
#endif
Rboolean Rf_isLanguage(SEXP value);
#ifndef R_NO_REMAP
#define isLanguage Rf_isLanguage
#endif
Rboolean Rf_isList(SEXP value);
#ifndef R_NO_REMAP
#define isList Rf_isList
#endif
Rboolean Rf_isLogical(SEXP value);
#ifndef R_NO_REMAP
#define isLogical Rf_isLogical
#endif
Rboolean Rf_isNewList(SEXP value);
#ifndef R_NO_REMAP
#define isNewList Rf_isNewList
#endif
Rboolean Rf_isNull(SEXP value);
#ifndef R_NO_REMAP
#define isNull Rf_isNull
#endif
Rboolean Rf_isPairList(SEXP value);
#ifndef R_NO_REMAP
#define isPairList Rf_isPairList
#endif
Rboolean Rf_isPrimitive(SEXP value);
#ifndef R_NO_REMAP
#define isPrimitive Rf_isPrimitive
#endif
Rboolean Rf_isReal(SEXP value);
#ifndef R_NO_REMAP
#define isReal Rf_isReal
#endif
Rboolean Rf_isString(SEXP value);
#ifndef R_NO_REMAP
#define isString Rf_isString
#endif
Rboolean Rf_isSymbol(SEXP value);
#ifndef R_NO_REMAP
#define isSymbol Rf_isSymbol
#endif
Rboolean Rf_isVector(SEXP value);
#ifndef R_NO_REMAP
#define isVector Rf_isVector
#endif
Rboolean Rf_isVectorAtomic(SEXP value);
#ifndef R_NO_REMAP
#define isVectorAtomic Rf_isVectorAtomic
#endif
Rboolean Rf_isVectorList(SEXP value);
#ifndef R_NO_REMAP
#define isVectorList Rf_isVectorList
#endif

Arguments

value

An arbitrary R value.

Value and side effects

Rf_isComplex
Rf_isEnvironment
Rf_isExpression
Rf_isInteger
Rf_isLogical
Rf_isNull
Rf_isReal
Rf_isSymbol

Returns TRUE if TYPEOF(value) is equal to the corresponding type code, otherwise FALSE.

Rf_isString

Returns TRUE if value is of type STRSXP (not CHARSXP).

Rf_isFunction

Returns TRUE if value is a closure (CLOSXP) or one of the callable primitives (BUILTINSXP / SPECIALSXP).

Rf_isLanguage

Returns TRUE if value is a language pairlist, i.e. LANGSXP or NILSXP.

Note that the test differs from R’s is.language(), which will also return TRUE for SYMSXP or EXPRSXP.

Rf_isList

Returns TRUE if value is a pairlist, i.e., LISTSXP or NILSXP.

Rf_isNewList

Returns TRUE if value is a NILSXP or a VECSXP.

Rf_isPairList

Returns TRUE if value is of a type implemented as Lisp-style pairlists, i.e., one of NILSXP, LISTSXP, LANGSXP, DOTSXP (new in 3.2.0).

Rf_isPrimitive

Returns TRUE if value is a primitive function: BUILTINSXP or SPECIALSXP.

Rf_isVector
Rf_isVectorAtomic
Rf_isVectorList

isVectorAtomic returns TRUE if value has one of the atomic vector types: LGLSXP, INTSXP, REALSXP, CPLXSXP, STRSXP, RAWSXP.

isVectorList returns TRUE if value has one of the recursive vector list types: VECSXP, EXPRSXP.

isVector returns TRUE if either isVectorAtomic or isVectorList is TRUE.


Next: , Previous: , Up: Functions   [Index]

isArray

#include <Rinternals.h>
Rboolean Rf_isArray(SEXP value);
#ifndef R_NO_REMAP
#define isArray Rf_isArray
#endif
Rboolean Rf_isDataFrame(SEXP value);
#ifndef R_NO_REMAP
#define isDataFrame Rf_isDataFrame
#endif
Rboolean Rf_isFactor(SEXP value);
#ifndef R_NO_REMAP
#define isFactor Rf_isFactor
#endif
Rboolean Rf_isMatrix(SEXP value);
#ifndef R_NO_REMAP
#define isMatrix Rf_isMatrix
#endif
Rboolean Rf_isNumber(SEXP value);
#ifndef R_NO_REMAP
#define isNumber Rf_isNumber
#endif
Rboolean Rf_isNumeric(SEXP value);
#ifndef R_NO_REMAP
#define isNumeric Rf_isNumeric
#endif
Rboolean Rf_isObject(SEXP value);
#ifndef R_NO_REMAP
#define isObject Rf_isObject
#endif
Rboolean Rf_isOrdered(SEXP value);
#ifndef R_NO_REMAP
#define isOrdered Rf_isOrdered
#endif
Rboolean Rf_isS4(SEXP value);
#ifndef R_NO_REMAP
#define isS4 Rf_isS4
#endif
Rboolean Rf_isTs(SEXP value);
#ifndef R_NO_REMAP
#define isTs Rf_isTs
#endif
Rboolean Rf_isUnordered(SEXP value);
#ifndef R_NO_REMAP
#define isUnordered Rf_isUnordered
#endif

Arguments

value

An arbitrary R value.

Value and side effects

Rf_isArray

Returns TRUE if value has a valid dim attribite: of integer type, with a nonzero length.

Rf_isDataFrame

Returns TRUE if value inherits from data.frame.

Versions: This function appeared in version 4.5.0.

Rf_isFactor
Rf_isOrdered
Rf_isUnordered

isFactor returns TRUE if value is of integer type and inherits from factor. isOrdered additionally tests that value inherits from ordered. Converesly, isUnordered tests that a factor value does not inherit from ordered.

Rf_isMatrix

Returns TRUE if value is of a vector type and has a two-element integer attribute dim.

Rf_isNumber

Returns TRUE if value can be interpreted as a number (as opposed to a category code): LGLSXP, REALSXP, CPLXSXP are accepted, and so are INTSXP that don’t inherit from factor.

Rf_isNumeric

Returns TRUE if value can be interpreted as a number (as opposed to a category code): LGLSXP and REALSXP are accepted, and so are INTSXP that don’t inherit from factor. Unlike isNumber, CPLXSXP are not accepted.

Rf_isObject

Returns TRUE if the object bit is set in value, i.e. it’s a formal object or has a non-empty class attribute.

Rf_isS4

Returns TRUE if value is an S4 object. S4 objects will either have the SEXPTYPE of their base class or OBJSXP if they don’t inherit from a primitive base class, so there is a separate bit marking an object as an S4 object.

Rf_isTs

Returns TRUE if value can be considered a time series object, i.e., if it has a non-empty tsp attribute.


Next: , Previous: , Up: Functions   [Index]

coerceVector

#include <Rinternals.h>
SEXP Rf_coerceVector(
 SEXP x, SEXPTYPE type
);
#ifndef R_NO_REMAP
#define coerceVector Rf_coerceVector
#endif

Arguments

x

An arbitrary R value.

type

The desired type to convert x to.

Value and side effects

Allocates and returns a copy x converted to SEXPTYPE type, if possible. Not all conversions make sense. An impossible conversion will raise an R error.


Next: , Previous: , Up: Functions   [Index]

setAttrib

#include <Rinternals.h>
SEXP Rf_getAttrib(
 SEXP vec, SEXP name
);
#ifndef R_NO_REMAP
#define getAttrib Rf_getAttrib
#endif
SEXP Rf_setAttrib(
 SEXP vec, SEXP name, SEXP val
);
#ifndef R_NO_REMAP
#define setAttrib Rf_setAttrib
#endif

Arguments

vec

An arbitrary R value that can have attributes. It is not allowed to get attributes of a NILSXP or get/set attributes for a CHARSXP.

name

The name of the attribute as a SYMSXP or a one-element STRSXP.

val

The desired value of the attribute.

Value and side effects

Rf_getAttrib

Returns the value of the attribute, or R_NilValue if the attribute was not set. Raises an error if vec is of type CHARSXP.

Rf_setAttrib

Sets the value of the given attribute, modifying vec. Removes the attribute if val == R_NilValue. Raises an error if vec is of type CHARSXP or NILSXP.


Next: , Previous: , Up: Functions   [Index]

GetArrayDimnames

#include <Rinternals.h>
SEXP Rf_GetArrayDimnames(SEXP x);
#ifndef R_NO_REMAP
#define GetArrayDimnames Rf_GetArrayDimnames
#endif

Arguments

x

An arbitrary R value that can have dimensions.

Value and side effects

Returns the value of the dimnames attribute, possibly R_NilValue.


Next: , Previous: , Up: Functions   [Index]

GetColNames

#include <Rinternals.h>
SEXP Rf_GetColNames(SEXP dn);
#ifndef R_NO_REMAP
#define GetColNames Rf_GetColNames
#endif
SEXP Rf_GetRowNames(SEXP dn);
#ifndef R_NO_REMAP
#define GetRowNames Rf_GetRowNames
#endif

Arguments

dn

The value of the dimnames attribute of an R value (see GetArrayDimnames).

Value and side effects

Rf_GetColNames

Returns the column names of the original value.

Rf_GetRowNames

Returns the row names of the original value.

These functions were useful for portability during the times when R was switching from pairlist-based dimnames to VECSXP-based dimnames. Nowadays, dimnames are always adjusted to be a vector.


Next: , Previous: , Up: Functions   [Index]

GetMatrixDimnames

#include <Rinternals.h>
void Rf_GetMatrixDimnames(
 SEXP x, SEXP *rl, SEXP *cl,
 const char **rn, const char **cn
);
#ifndef R_NO_REMAP
#define GetMatrixDimnames Rf_GetMatrixDimnames
#endif

Arguments

x

An arbitrary R value that can have dimensions.

rl

A pointer to a SEXP that will point to the row names of x.

cl

A pointer to a SEXP that will point to the column names of x.

rn

A pointer to a const char * that will point to the name of the row dimension of x.

cn

A pointer to a const char * that will point to the name of the column dimension of x.

Value and side effects

If x has dimnames, populates the output arguments rl, cl with rownames(x), colnames(x). Sets them to R_NilValue if the dimension names are not set.

If dimnames(x) is named, the strings pointed to by rn, cn may be allocated using R_alloc and thus subject to vmaxset memory management. Otherwise, the pointers rn, cn will be set to NULL.


Next: , Previous: , Up: Functions   [Index]

dimnamesgets

#include <Rinternals.h>
SEXP Rf_dimnamesgets(
 SEXP vec, SEXP val
);
#ifndef R_NO_REMAP
#define dimnamesgets Rf_dimnamesgets
#endif
SEXP Rf_dimgets(
 SEXP vec, SEXP val
);
#ifndef R_NO_REMAP
#define dimgets Rf_dimgets
#endif
SEXP Rf_namesgets(
 SEXP vec, SEXP val
);
#ifndef R_NO_REMAP
#define namesgets Rf_namesgets
#endif

Arguments

vec

An R vector.

For namesgets, can also be a pairlist.

val

The desired attribute value for vec.

For dimnamesgets: a (possibly named) VECSXP list, or NILSXP. Must be either of length zero (thus removing the dimnames) or of the same length as dim(vec), with the length of each element of val equal to the corresponding element of dim(vec).

For dimgets: a vector of nonzero length, losslessly convertible to INTSXP, such that prod(val) == length(vec).

For namesgets: a vector convertible to STRSXP. Will be recycled if shorter than vec.

Value and side effects

Modifies the attributes (dimnames(), dim(), or names()) of vec in place and returns vec.

Currently, setting dim(vec) removes dimnames(vec).


Next: , Previous: , Up: Functions   [Index]

install

#include <Rinternals.h>

SEXP Rf_install(const char * name);
#ifndef R_NO_REMAP
#define install Rf_install
#endif

SEXP Rf_installChar(SEXP x);
SEXP Rf_installTrChar(SEXP x);

SEXP PRINTNAME(SEXP s);

Arguments

name

A native-encoding string giving the value of the symbol to create.

x

A CHARSXP containing the name of the desired symbol. Will be translated into the native encoding if required.

s

A SYMSXP value.

Value and side effects

Rf_install
Rf_installChar
Rf_installTrChar

Locates and returns an existing symbol with the given name, or creates, installs and returns a new one. Symbols are currently not garbage-collected, so installing a symbol once should be sufficient, and the returned value is safe to retain.

Versions: installChar and Rf_installTrChar solidified in their current form, including a remap from installChar to Rf_installTrChar, in version 4.0.0. Prior to version 3.5.0, the function Rf_installChar performed install(CHAR(x)) directly, discarding the encoding information. The three names installChar, Rf_installChar, Rf_installTrChar have been declared as part of the API in version 4.5.0.

PRINTNAME

Returns the name of the symbol as a CHARSXP value.


Next: , Previous: , Up: Functions   [Index]

mkNamed

#include <Rinternals.h>
SEXP Rf_mkNamed(
 SEXPTYPE typ, const char ** names
);
#ifndef R_NO_REMAP
#define mkNamed Rf_mkNamed
#endif

Arguments

typ

The desired type of the vector, must be compatible with allocVector.

names

An array of strings in the native encoding to take the names of the vector elements from. Must be terminated by "", an empty string.

Value and side effects

Allocates and returns an R vector of type typ with names taken from names. No additional vector element is created for the terminator in names.


Next: , Previous: , Up: Functions   [Index]

classgets

#include <Rinternals.h>
SEXP Rf_classgets(
 SEXP vec, SEXP klass
);
#ifndef R_NO_REMAP
#define classgets Rf_classgets
#endif

Arguments

vec

An R value that can have attributes.

klass

An R value of type NILSXP or STRSXP.

Value and side effects

Sets the class attribute of vec to klass, altering vec by reference. Sets or resets the object bit depending on whether klass is non-empty.

Raises an error if arguments are of wrong type or when trying to set the factor class on a non-INTSXP vec.


Next: , Previous: , Up: Functions   [Index]

allocList

#include <Rinternals.h>
SEXP Rf_allocList(int n);
#ifndef R_NO_REMAP
#define allocList Rf_allocList
#endif
SEXP Rf_allocLang(int n);
#ifndef R_NO_REMAP
#define allocLang Rf_allocLang
#endif

Arguments

n

The number of elements to allocate.

Value and side effects

Rf_allocList

Returns the head of the newly-allocated pairlist, a value of type LISTSXP. The CAR of each pair references the R_NilValue and the CDR references the next pair in the list (R_NilValue for the last element).

Rf_allocLang

Same as allocList, except the returned value is of type LANGSXP. The following pairs in the list are still of type LISTSXP.


Next: , Previous: , Up: Functions   [Index]

STRING_ELT

#include <Rinternals.h>
SEXP STRING_ELT(
 SEXP x, R_xlen_t i
);
void SET_STRING_ELT(
 SEXP x, R_xlen_t i, SEXP v
);
const SEXP * STRING_PTR_RO(SEXP x);

Arguments

x

An R vector of type STRSXP.

i

An zero-based index into x.

v

An R value of type CHARSXP.

Value and side effects

STRING_ELT

Returns the CHARSXP element of the string vector x at index i. Raises an error if x not of type STRSXP. If i is out of range 0:(XLENGTH(x) - 1), behaviour is undefined.

SET_STRING_ELT

Sets the CHARSXP element given in v at the index i inside the STRSXP vector x. Raises an error if any of the types don’t match or if i is out of range.

For a non-ALTREP x, such an assignment will not perform garbage collection, so use of idioms such as SET_STRING_ELT(x, i, mkChar("foo")) on a freshly allocated x is safe.

STRING_PTR_RO

Returns a pointer to the beginning of a buffer of SEXP[XLENGTH(x)], which correspond to the CHARSXP objects comprising x. Modification of x through this pointer is prohibited. If the length of x is zero, behaviour is undefined.

Versions: This function appeared in version 3.5.0.


Next: , Previous: , Up: Functions   [Index]

mkChar

#include <Rinternals.h>
SEXP Rf_mkChar(const char * name);
#ifndef R_NO_REMAP
#define mkChar Rf_mkChar
#endif
SEXP Rf_mkCharLen(
 const char * name, int len
);
#ifndef R_NO_REMAP
#define mkCharLen Rf_mkCharLen
#endif
SEXP Rf_mkCharCE(
 const char * name, cetype_t enc
);
#ifndef R_NO_REMAP
#define mkCharCE Rf_mkCharCE
#endif
SEXP Rf_mkCharLenCE(
 const char * name, int len, cetype_t enc
);
#ifndef R_NO_REMAP
#define mkCharLenCE Rf_mkCharLenCE
#endif
#define CHAR(x) R_CHAR(x)
const char * R_CHAR(SEXP x);
cetype_t Rf_getCharCE(SEXP x);
#ifndef R_NO_REMAP
#define getCharCE Rf_getCharCE
#endif

Arguments

name

The contents of the string to be created.

len

The length of the string starting at name in bytes.

enc

The encoding of the string (see cetype_t). Must be one of CE_NATIVE, CE_UTF8, CE_LATIN1, CE_BYTES.

x

An R value of type CHARSXP.

Value and side effects

Rf_mkChar
Rf_mkCharLen
Rf_mkCharCE

Versions: Appeared in 2.7.0

Rf_mkCharLenCE

Returns an R value of type CHARSXP referencing the specified string with relevant encoding bits set. May return a new value, or one that already exists in the string cache.

Like other values in R, CHARSXPs are subject to garbage collection. They are usually protected indirectly by being assigned into STRSXP values using SET_STRING_ELT.

R_CHAR

Returns the pointer to the 0-terminated C string represented by x. The data is stored in the declared encoding of the string, so this should only be used for strings known to be stored in ASCII.

Rf_getCharCE

Returns the encoding of the string.

Versions: Appeared in 2.7.0

See translateChar for guaranteed access to the string data in a predictable encoding.


Next: , Previous: , Up: Functions   [Index]

R_mkClosure

#include <Rinternals.h>
SEXP R_mkClosure(
 SEXP formals, SEXP body, SEXP rho
);
SEXP R_ClosureFormals(SEXP closure);
SEXP R_ClosureBody(SEXP closure);
SEXP R_ClosureEnv(SEXP closure);
SEXP R_ClosureExpr(SEXP closure);
SEXP R_BytecodeExpr(SEXP bytecode);

Arguments

formals

A named pairlist defining the formal arguments of the closure. The names (TAGs) must be of type SYMSXP, and the values must be unevaluated expressions (of any type suitable for evaluation, which includes plain values) setting their default values, or R_MissingArg if there is none. A TAG of R_DotsSymbol (...) has the usual meaning of ellipsis in R.

body

The body of the function. Typically, a LANGSXP list expressing a function call, which can be to the { operator for a series of expressions. Types CLOSXP, BUILTINSXP, SPECIALSXP, DOTSXP, ANYSXP are explicitly disallowed.

rho

The evironment that will be the base of the call frame when the function is called; must be of type ENVSXP.

closure

A CLOSXP object.

bytecode

A BCODESXP object of a previously exctacted body of a closure.

Value and side effects

R_mkClosure

Constructs and returns a closure, an R object of type CLOSXP.

Versions: This function appeared in version 4.5.0.

R_ClosureFormals

Returns the LISTSXP defining the formal arguments of a given closure.

Versions: This function appeared in version 4.5.0.

R_ClosureBody

Returns the body of the given closure. For a compiled closure, this will be a BCODESXP value.

Versions: This function appeared in version 4.5.0.

R_ClosureEnv

Returns the ENVSXP of the environment of a given closure.

Versions: This function appeared in version 4.5.0.

R_ClosureExpr

Returns the body of the given closure. If it had been compiled, the return value is the original, non-compiled expression, or a NILSXP if the bytecode object does not reference any constants.

R_BytecodeExpr

Returns the original, non-compiled expression from a BCODESXP, or a NILSXP if it does not reference any constants.

Versions: This function appeared in version 3.4.0.


Next: , Previous: , Up: Functions   [Index]

defineVar

#include <Rinternals.h>
void Rf_defineVar(
 SEXP symbol, SEXP value, SEXP rho
);
#ifndef R_NO_REMAP
#define defineVar Rf_defineVar
#endif
void Rf_setVar(
 SEXP symbol, SEXP value, SEXP rho
);
#ifndef R_NO_REMAP
#define setVar Rf_setVar
#endif

Arguments

symbol

The name of the variable to bind, a SYMSXP.

value

An arbitrary R value to bind to the variable.

rho

The environment in which to perform the assignment (defineVar) or to start the search for a defined symbol to overwrite (setVar). Must be an ENVSXP.

Value and side effects

Rf_defineVar

Binds the value to the given symbol in the environment rho without making a copy of it.

Rf_setVar

Searches rho and its enclosing envrionments for an already defined symbol and binds value to it without making a copy. If none of the environments have symbol set, binds it in R_GlobalEnv.

Versions: These functions appeared in version 4.5.0.


Next: , Previous: , Up: Functions   [Index]

R_getVar

#include <Rinternals.h>
SEXP R_getVar(
 SEXP sym, SEXP rho,
 Rboolean inherits
);
SEXP R_getVarEx(
 SEXP sym, SEXP rho,
 Rboolean inherits, SEXP ifnotfound
);

Arguments

sym

The name of the variable, must be a SYMSXP.

rho

The environment to search the variable in, must be an ENVSXP.

inherits

Whether to keep looking for the variable in the enclosing environments.

ifnotfound

What to return instead of the variable that has not been found.

Value and side effects

R_getVar

Returns the value of the requested variable, or raises an error if it was not found.

R_getVarEx

Returns the value of the requested variable, or ifnotfound if there was no such variable.


Next: , Previous: , Up: Functions   [Index]

R_NewEnv

#include <Rinternals.h>
SEXP R_NewEnv(
 SEXP enclos, int hash, int size
);

Arguments

enclos

The enclosing environment. Must be an ENVSXP.

hash

If nonzero, the environment will use a hash table to look up the variables.

size

The initial size of the hash; ignored if hash == 0. Will use a safe default if size <= 0.

Value and side effects

Returns the new environment created with the specified settings, like new.env() in R.

Versions: This function appeared in version 4.1.0.


Next: , Previous: , Up: Functions   [Index]

asInteger

#include <Rinternals.h>
int Rf_asInteger(SEXP x);
#ifndef R_NO_REMAP
#define asInteger Rf_asInteger
#endif
int Rf_asLogical(SEXP x);
#ifndef R_NO_REMAP
#define asLogical Rf_asLogical
#endif
double Rf_asReal(SEXP x);
#ifndef R_NO_REMAP
#define asReal Rf_asReal
#endif
Rcomplex Rf_asComplex(SEXP x);
#ifndef R_NO_REMAP
#define asComplex Rf_asComplex
#endif
SEXP Rf_asChar(SEXP x);
#ifndef R_NO_REMAP
#define asChar Rf_asChar
#endif
SEXP Rf_asCharacterFactor(SEXP x);
#ifndef R_NO_REMAP
#define asCharacterFactor Rf_asCharacterFactor
#endif

Arguments

x

An R value that could be converted to the desired type:

Rf_asInteger

RAWSXP, LGLSXP, INTSXP, REALSXP (may warn), CPLXSXP (may warn), STRSXP (may warn), CHARSXP (may warn)

Rf_asLogical

LGLSXP, INTSXP, REALSXP, CPLXSXP, STRSXP, RAWSXP, CHARSXP

Rf_asReal

LGLSXP, INTSXP, REALSXP, CPLXSXP (may warn), STRSXP (may warn) CHARSXP (may warn)

Rf_asComplex

LGLSXP, INTSXP, REALSXP, CPLXSXP, STRSXP (may warn), CHARSXP (may warn)

Rf_asChar

LGLSXP, INTSXP, REALSXP, CPLXSXP, STRSXP, CHARSXP, SYMSXP

Rf_asCharacterFactor

A valid factor.

Value and side effects

Rf_asInteger
Rf_asLogical
Rf_asReal
Rf_asComplex

Returns the result of the conversion as the corresponding primitive C type. If x is a vector, the first element is used. Zero-length vectors are converted into a corresponding NA value. If the conversion is lossy, a warning is raised; if the type of x is unsupported, an error is raised.

Rf_asChar

Returns a string representation of x as a CHARSXP value. If x is a vector, the first element is used. If the type is unsupported or x is zero-length, returns NA_STRING.

Rf_asCharacterFactor

Returns a STRSXP vector of the same length as x, same as as.character(x) in R.

Versions

Support for RAWSXP in Rf_asInteger() appeared in 4.5.0. Support for STRSXP and CHARSXP appeared in 2.6.0 for Rf_asInteger(), Rf_asReal(), Rf_asComplex(). Support for CHARSXP in Rf_asChar() appeared in 2.6.0. Rf_asCharacterFactor appeared in 2.9.0.


Next: , Previous: , Up: Functions   [Index]

ScalarReal

#include <Rinternals.h>
SEXP Rf_ScalarReal(double x);
#ifndef R_NO_REMAP
#define ScalarReal Rf_ScalarReal
#endif
SEXP Rf_ScalarInteger(int x);
#ifndef R_NO_REMAP
#define ScalarInteger Rf_ScalarInteger
#endif
SEXP Rf_ScalarLogical(int x);
#ifndef R_NO_REMAP
#define ScalarLogical Rf_ScalarLogical
#endif
SEXP Rf_ScalarComplex(Rcomplex x);
#ifndef R_NO_REMAP
#define ScalarComplex Rf_ScalarComplex
#endif
SEXP Rf_ScalarRaw(Rbyte x);
#ifndef R_NO_REMAP
#define ScalarRaw Rf_ScalarRaw
#endif
SEXP Rf_ScalarString(SEXP x);
#ifndef R_NO_REMAP
#define ScalarString Rf_ScalarString
#endif

Arguments

x

A scalar value of the appropriate type (CHARSXP for ScalarString).

Value and side effects

Allocates and returns a one-element vector of the corresponding SEXPTYPE (STRSXP for ScalarString).

Versions: From version 2.4.0 Rf_ScalarLogical coerces all non-zero, non-NA values to TRUE.


Next: , Previous: , Up: Functions   [Index]

mkString

#include <Rinternals.h>
SEXP Rf_mkString(const char * s);
#ifndef R_NO_REMAP
#define mkString Rf_mkString
#endif

Arguments

s

A 0-terminated C string in the native encoding.

Value and side effects

Allocates and returns a one-element STRSXP vector containing the string s.


Next: , Previous: , Up: Functions   [Index]

CONS

#include <Rinternals.h>
SEXP Rf_cons(SEXP car, SEXP cdr);
#ifndef R_NO_REMAP
#define cons Rf_cons
#endif
#define CONS(car, cdr) Rf_cons(car, cdr)
SEXP Rf_list1(SEXP s);
#ifndef R_NO_REMAP
#define list1 Rf_list1
#endif
SEXP Rf_list2(
 SEXP s, SEXP t
);
#ifndef R_NO_REMAP
#define list2 Rf_list2
#endif
SEXP Rf_list3(
 SEXP s, SEXP t, SEXP u
);
#ifndef R_NO_REMAP
#define list3 Rf_list3
#endif
SEXP Rf_list4(
 SEXP s, SEXP t,
 SEXP u, SEXP v
);
#ifndef R_NO_REMAP
#define list4 Rf_list4
#endif
SEXP Rf_list5(
 SEXP s, SEXP t, SEXP u,
 SEXP v, SEXP w
);
#ifndef R_NO_REMAP
#define list5 Rf_list5
#endif
SEXP Rf_list6(
 SEXP s, SEXP t, SEXP u,
 SEXP v, SEXP w, SEXP x
);
#ifndef R_NO_REMAP
#define list6 Rf_list6
#endif

Arguments

car, cdr

The two values to be referenced by the returned pair.

s, t, u, v, w, x

The elements to be included in the returned pairlist, in order.

Value and side effects

Rf_cons

Returns a pair of type LISTSXP, the basis of Lisp-style pairlists. The resulting value has CAR(value) == car, CDR(value) == cdr, and TAG(value) == R_NilValue.

Rf_list1
Rf_list2
Rf_list3
Rf_list4
Rf_list5
Rf_list6

Construct a short Lisp-style pairlist and return its head pair. The resulting value has CAR(value) == s, and CDR(value) points to the next pair, or R_NilValue if there are no more elements in the list.

Versions: The function Rf_list6 appeared in version 3.4.0.

Versions: Prior to version 4.4.0, CONS did not work with R_NO_REMAP set because it expanded to cons instead of Rf_cons.


Next: , Previous: , Up: Functions   [Index]

LCONS

#include <Rinternals.h>
SEXP Rf_lcons(SEXP car, SEXP cdr);
#ifndef R_NO_REMAP
#define lcons Rf_lcons
#endif
#define LCONS(car, cdr) Rf_lcons(car, cdr)
SEXP Rf_lang1(SEXP s);
#ifndef R_NO_REMAP
#define lang1 Rf_lang1
#endif
SEXP Rf_lang2(
 SEXP s, SEXP t
);
#ifndef R_NO_REMAP
#define lang2 Rf_lang2
#endif
SEXP Rf_lang3(
 SEXP s, SEXP t, SEXP u
);
#ifndef R_NO_REMAP
#define lang3 Rf_lang3
#endif
SEXP Rf_lang4(
 SEXP s, SEXP t,
 SEXP u, SEXP v
);
#ifndef R_NO_REMAP
#define lang4 Rf_lang4
#endif
SEXP Rf_lang5(
 SEXP s, SEXP t, SEXP u,
 SEXP v, SEXP w
);
#ifndef R_NO_REMAP
#define lang5 Rf_lang5
#endif
SEXP Rf_lang6(
 SEXP s, SEXP t, SEXP u,
 SEXP v, SEXP w, SEXP x
);
#ifndef R_NO_REMAP
#define lang6 Rf_lang6
#endif

Arguments

car, cdr

The two values to be referenced by the returned LANGSXP pair.

s, t, u, v, w, x

The elements to be included in the returned language pairlist, in order.

Value and side effects

Rf_lcons

Returns a language pair object of type LANGSXP. The resulting value has CAR(value) == car, CDR(value) == cdr, and TAG(value) == R_NilValue.

Rf_lang1
Rf_lang2
Rf_lang3
Rf_lang4
Rf_lang5
Rf_lang6

Construct a short language pairlist and return its head pair. The resulting value has CAR(value) == s, and CDR(value) points to the next pair, or R_NilValue if there are no more elements in the list. Only the head of the list is of type LANGSXP; the rest of the list consists of pairs of type LISTSXP.

Versions: Prior to version 4.4.0, LCONS did not work with R_NO_REMAP set because it expanded to lcons instead of Rf_lcons. Version 2.12.0 introduced Rf_lang5 and Rf_lang6.


Next: , Previous: , Up: Functions   [Index]

elt

#include <Rinternals.h>
SEXP Rf_elt(SEXP list, int i);
#ifndef R_NO_REMAP
#define elt Rf_elt
#endif

Arguments

list

A pairlist object: LISTSXP, LANGSXP, or NILSXP.

i

A zero-based index into list.

Value and side effects

Returns the ith element of the list, that is, CAR(CDR(...(CDR(list)))), where the CDR(...) is repeated i times.

If i is outside the range of valid indices, returns R_NilValue.


Next: , Previous: , Up: Functions   [Index]

lastElt

#include <Rinternals.h>
SEXP Rf_lastElt(SEXP list);
#ifndef R_NO_REMAP
#define lastElt Rf_lastElt
#endif

Arguments

list

A pairlist object: LISTSXP, LANGSXP, or NILSXP.

Value and side effects

Returns the last element of the list, that is, CAR(tail) for such tail = CDR(...(CDR(list))) that CDR(tail) == R_NilValue.

If the list was empty (NILSXP) in the first place, returns R_NilValue.


Next: , Previous: , Up: Functions   [Index]

nthcdr

#include <Rinternals.h>
SEXP Rf_nthcdr(SEXP s, int n);
#ifndef R_NO_REMAP
#define nthcdr Rf_nthcdr
#endif

Arguments

s

An R value for which CDR is applicable: LISTSXP, LANGSXP, DOTSXP, NILSXP.

n

A zero-based index into s.

Value and side effects

If s is long enough, returns CDR(...(CDR(s))) where CDR(...) is repeated n times. Raises an error if the list is too short, that is, an R_NilValue is encountered before an intended CDR(...) call.


Next: , Previous: , Up: Functions   [Index]

str2type

#include <Rinternals.h>
SEXPTYPE Rf_str2type(const char * name);
#ifndef R_NO_REMAP
#define str2type Rf_str2type
#endif
SEXP Rf_type2str(SEXPTYPE type);
#ifndef R_NO_REMAP
#define type2str Rf_type2str
#endif
SEXP Rf_type2str_nowarn(SEXPTYPE type);
#ifndef R_NO_REMAP
#define type2str_nowarn Rf_type2str_nowarn
#endif
const char * Rf_type2char(SEXPTYPE type);
#ifndef R_NO_REMAP
#define type2char Rf_type2char
#endif

Arguments

name

One of the type names as a 0-terminated C string. See SEXPTYPE.

type

A type code for an R value.

Value and side effects

Rf_str2type

Returns the SEXPTYPE that corresponds to the given type name, or (SEXPTYPE)-1 if the type name is invalid.

Versions: This function appeared in version 2.5.0.

Rf_type2str_nowarn

Returns the type name of the given SEXPTYPE as a CHARSXP. If type is not a valid type code, behaviour is undefined, but the function intends to return R_NilValue.

Versions: This function appeared in version 3.2.0.

Rf_type2str

Returns the type name of the given SEXPTYPE as a CHARSXP. If type is not a valid type code, behaviour is undefined, but the function intends to raise an R warning and return unknown type #type as a CHARSXP.

Versions: This function appeared in version 2.5.0.

Rf_type2char

Like type2str, including the undefined behaviour, but returns a C string instead of a CHARSXP.

Versions: This function appeared in version 2.5.0.


Next: , Previous: , Up: Functions   [Index]

R_ParentEnv

#include <Rinternals.h>
SEXP R_ParentEnv(SEXP env);

Arguments

env

An R environment (of type ENVSXP).

Value and side effects

Returns the enclosing environment of env, which will usually be of type ENVSXP, except for the special environment R_EmptyEnv, which terminates the environment chain; its enclosing environment is R_NilValue.

Versions: This function appeared in version 4.5.0.


Next: , Previous: , Up: Functions   [Index]

inherits

#include <Rinternals.h>
Rboolean Rf_inherits(
 SEXP s, const char * name
);
#ifndef R_NO_REMAP
#define inherits Rf_inherits
#endif

Arguments

s

An arbitrary R value.

name

An R class name as a zero-terminated C string in the native encoding.

Value and side effects

Returns TRUE if s has the object bit set and its class attribute vector contains a string equal to name; otherwise returns FALSE.


Next: , Previous: , Up: Functions   [Index]

topenv

#include <Rinternals.h>
SEXP Rf_topenv(
 SEXP target, SEXP envir
);
#ifndef R_NO_REMAP
#define topenv Rf_topenv
#endif

Arguments

target

The environment to look for in the environment chain starting from envir.

envir

The starting environment to look from.

Value and side effects

Returns the “top level” environment of envir, that is, the first environment in the chain formed by the enclosing environments that satisfies any of the criteria:

  • is equal to target
  • is equal to R_GlobalEnv, the global environment
  • is equal to R_BaseEnv, the base environment
  • is equal to R_BaseNamespace
  • is a package exports environment
  • is a package namespace environment
  • contains .packageName (and thus is a namespace environment)

If no environments in the chain satisfy the condition, returns R_GlobalEnv.

Versions: This function was declared in Rinternals.h in version 3.5.0.


Next: , Previous: , Up: Functions   [Index]

GetOption1

#include <Rinternals.h>
SEXP Rf_GetOption1(SEXP tag);
#ifndef R_NO_REMAP
#define GetOption1 Rf_GetOption1
#endif
int Rf_GetOptionWidth(void);
#ifndef R_NO_REMAP
#define GetOptionWidth Rf_GetOptionWidth
#endif

Arguments

tag

The name of the option to look up, as a SYMSXP value.

Value and side effects

Rf_GetOption1

Returns the value of the option, or R_NilValue if it was not found.

Rf_GetOptionWidth

Returns the value of the width option as a C integer. If it somehow became invalid (not an integer, or outside the safe range), returns 80, with a warning.


Next: , Previous: , Up: Functions   [Index]

duplicate

#include <Rinternals.h>
SEXP Rf_duplicate(SEXP s);
#ifndef R_NO_REMAP
#define duplicate Rf_duplicate
#endif
SEXP Rf_shallow_duplicate(SEXP s);
#ifndef R_NO_REMAP
#define shallow_duplicate Rf_shallow_duplicate
#endif
void DUPLICATE_ATTRIB(SEXP to, SEXP from);
void SHALLOW_DUPLICATE_ATTRIB(
 SEXP to, SEXP from
);

Arguments

s

An arbitrary R value to duplicate.

to

The R value to set attibutes onto.

from

The R value to take attributes from.

Value and side effects

Rf_duplicate

Returns a by-value copy of s. For reference-semantics objects (NILSXP, SYMSXP, ENVSXP, SPECIALSXP, BUILTINSXP, EXTPTRSXP, BCODESXP, WEAKREFSXP, CHARSXP, PROMSXP), where the reference is the value, returns s itself. Duplicating a CLOSXP results in a new object that references the same formals, body, and enclosing environment. For the remaining value types (LISTSXP, LANGSXP, DOTSXP, EXPRSXP, VECSXP, LGLSXP, INTSXP, REALSXP, CPLXSXP, RAWSXP, STRSXP), the result is a new object with the same contents as s that can be changed without affecting s.

Rf_shallow_duplicate

Same as duplicate, but list elements (such as CAR(...) for pairlists and VECTOR_ELT(...) for generic vectors) do not get duplicated and are instead shared.

Versions: This function appeared in version 3.1.0.

DUPLICATE_ATTRIB

Takes all attributes from from, duplicates them using duplicate(...) and sets them on to, modifying it by reference.

Versions: Before version 3.3.0, this function behaved like SHALLOW_DUPLICATE_ATTRIB.

SHALLOW_DUPLICATE_ATTRIB

Takes all attributes from from, duplicates them using shallow_duplicate(...) and sets them on to, modifying it by reference.

Versions: This function appeared in version 3.3.0.


Next: , Previous: , Up: Functions   [Index]

ANY_ATTRIB

#include <Rinternals.h>
int ANY_ATTRIB(SEXP x);
void CLEAR_ATTRIB(SEXP x);

Arguments

x

Any R value that can have attributes (see setAttrib).

Value and side effects

ANY_ATTRIB

Returns a non-zero value if x has any attributes; returns 0 if x has no attributes.

CLEAR_ATTRIB

Removes all attributes of x and clears its object bits, both regular and S4, altering it by reference.

Versions: These functions appeared in version 4.5.0.


Next: , Previous: , Up: Functions   [Index]

MARK_NOT_MUTABLE

#include <Rinternals.h>
int NO_REFERENCES(SEXP x);
#define MAYBE_REFERENCED(x) (! NO_REFERENCES(x))
int MAYBE_SHARED(SEXP x);
#define NOT_SHARED(x) (! MAYBE_SHARED(x))
void MARK_NOT_MUTABLE(SEXP x);

Arguments

x

An arbitrary R value.

Value and side effects

NO_REFERENCES
MAYBE_REFERENCED

If x has a reference count of 0, NO_REFERENCES(x) is nonzero, and MAYBE_REFERENCED(x) is 0. It is safe to modify x in this case.

Versions: These names appeared in version 3.1.0.

MAYBE_SHARED
NOT_SHARED

If x has a reference count above 1, MAYBE_SHARED(x) is nonzero, and NOT_SHARED(x) is 0. In this case, x should not be modified in place and must be duplicated (see duplicate) before performing any changes.

Versions: MAYBE_SHARED appeared in version 3.1.0. NOT_SHARED appeared in version 3.2.0.

Note: Except in very special and well understood circumstances, an argument passed down to C code should not be modified if it has a positive reference count, even if that count is equal to one.

MARK_NOT_MUTABLE

Sets the reference count of x to the maximum possible value, thus ensuring that it will stay marked as shared. Any code wanting to modify x will see it MAYBE_REFERENCED and have to duplicate it.

This is useful when keeping a pointer (see R_PreserveObject) to an object that is also accessible to other R code. Without an explicitly set reference count, mutators may modify the object in place.

Versions: This name appeared in version 3.1.0.

Versions: R switched from the previous mechanism of NAMED to reference counting in version 4.0.0. In previous versions of R, these names may be implemented as macros, directly accessing NAMED(x).


Next: , Previous: , Up: Functions   [Index]

SETCADDDR

#include <Rinternals.h>
SEXP CAR(SEXP e);
SEXP CDR(SEXP e);
SEXP TAG(SEXP e);
SEXP SETCAR(SEXP e, SEXP y);
SEXP SETCDR(SEXP e, SEXP y);
void SET_TAG(SEXP e, SEXP t);

SEXP CADR(SEXP e);
SEXP CADDR(SEXP e);
SEXP CADDDR(SEXP e);
SEXP CAD4R(SEXP e);
SEXP CAD5R(SEXP e);
SEXP CAAR(SEXP e);

SEXP CDAR(SEXP e);
SEXP CDDR(SEXP e);
SEXP CDDDR(SEXP e);

SEXP SETCADR(SEXP e, SEXP y);
SEXP SETCADDR(SEXP e, SEXP y);
SEXP SETCADDDR(SEXP e, SEXP y);
SEXP SETCAD4R(SEXP e, SEXP y);

Arguments

e

A pairlist R value: LISTSXP or LANGSXP, or DOTSXP. For read-only access (i.e. not SET), NILSXP is also accepted.

y

An arbitrary R value.

t

The desired tag of the pairlist element, typically a SYMSXP or NILSXP value.

Value and side effects

CAR
SETCAR

Returns (CAR) or sets and returns the new value (SETCAR) of the CAR field of the pair e. It is the same field that corresponds to the first argument of constructors CONS and LCONS.

CDR
SETCDR

Returns (CDR) or sets and returns the new value (SETCDR) of the CDR field of the pair e. It is the same field that corresponds to the second argument of constructors CONS and LCONS.

TAG
SET_TAG

Returns (TAG) or sets (SET_TAG) the TAG field of the pair e. The field is typically used to denote the name of the list element; in calls (LANGSXP pairlists), it denotes the name of the argument passed to the function.

CADR

Returns CAR(CDR(e)).

CADDR

Returns CAR(CDR(CDR(e))).

CADDDR

Returns CAR(CDR(CDR(CDR(e)))).

CAD4R

Returns CAR(CDR(CDR(CDR(CDR(e))))).

CAD5R

Returns CAR(CDR(CDR(CDR(CDR(CDR(e)))))).

Versions: Appeared in 4.3.0.

CAAR

Returns CAR(CAR(e)).

CDAR

Returns CDR(CAR(e)).

CDDR

Returns CDR(CDR(e)).

CDDDR

Returns CDR(CDR(CDR(e))).

Versions: Appeared in 3.2.0.

SETCADR

Shortcut for SETCAR(CDR(e), y).

SETCADDR

Shortcut for SETCAR(CDR(CDR(e)), y).

SETCADDDR

Shortcut for SETCAR(CDR(CDR(CDR(e))), y).

SETCAD4R

Shortcut for SETCAR(CDR(CDR(CDR(CDR(e)))), y).


Next: , Previous: , Up: Functions   [Index]

TYPEOF

#include <Rinternals.h>
int TYPEOF(SEXP x);

Arguments

x

An arbitrary R value.

Value and side effects

Returns the type code of x, see SEXPTYPE.


Next: , Previous: , Up: Functions   [Index]

ISNAN

#include <R_ext/Arith.h>

int R_isnancpp(double x);
#define ISNAN(x) /*...*/

int R_IsNaN(double x);

int R_IsNA(double x);
#define ISNA(x) R_IsNA(x)

int R_finite(double x);
#define R_FINITE(x) /*...*/

Arguments

x

A C value of type double.

Value and side effects

ISNAN
R_isnancpp

Returns a nonzero value if x is one of the not-a-number floating point values, which includes the NA value for doubles.

R_isnancpp has been implemented to work around some problems with the standard C++ headers and isnan as a macro.

R_IsNaN

Returns a nonzero value if x is a not-a-number floating point value and not the special NA value.

R_IsNA
ISNA

Returns a nonzero value if x is the double NA value.

R_finite
R_FINITE

Returns a nonzero value if x represents a real number: is neither +/-infinity, nor a not-a-number value.

R uses a special NaN payload to mark values as missing. Some modern processor architectures do not guarantee that the NaN payload will propagate across arithmetic operations, so an operation on an NA value that ought to result in a missing value may instead result in an ordinary NaN.


Next: , Previous: , Up: Functions   [Index]

eval

#include <Rinternals.h>
SEXP Rf_eval(SEXP e, SEXP, rho);
#ifndef R_NO_REMAP
#define eval Rf_eval
#endif

Arguments

e

An R value to evaluate. Value types (NILSXP, LISTSXP, LGLSXP, INTSXP, REALSXP, STRSXP, CPLXSXP, RAWSXP, OBJSXP, SPECIALSXP, BUILTINSXP, ENVSXP, CLOSXP, VECSXP, EXTPTRSXP, WEAKREFSXP, EXPRSXP) are accepted and returned as is. Executable types (BCODESXP, SYMSXP, PROMSXP; most typically LANGSXP) will be evaluated.

rho

The environment in which to evaluate e. Must be an ENVSXP.

Value and side effects

Evaluates e in the environment rho, which may cause arbitrary side effects, and returns its result (unless an error results in a long jump away from the call frame). May also raise an error if e is of an invalid type.


Next: , Previous: , Up: Functions   [Index]

findFun

#include <Rinternals.h>
SEXP Rf_findFun(
 SEXP symbol, SEXP rho
);
#ifndef R_NO_REMAP
#define findFun Rf_findFun
#endif

Arguments

symbol

The name of the function to find, must be a SYMSXP.

rho

The environment in which to look up the function, must be an ENVSXP.

Value and side effects

Looks up a function (of type CLOSXP, BUILTINSXP, SPECIALSXP) in rho and its enclosing environments and returns it. Raises an error if no such function could be found.


Next: , Previous: , Up: Functions   [Index]

R_ParseVector

#include <R_ext/Parse.h>
SEXP R_ParseVector(
 SEXP text, int n,
 ParseStatus * status, SEXP srcfile
);
#include <Rinternals.h>
SEXP R_ParseString(const char * str);
SEXP R_ParseEvalString(
 const char * str, SEXP env
);

Arguments

text

An STRSXP value containing the source code to parse.

n

The maximal number of expressions to parse. A negative number means no limit.

status

Pointer to a variable detailing the result of the operation.

srcfile

Either a length-one STRSXP value to be used as the filename in error messages, a value of class srcfile, or R_NilValue.

Versions: Added in 2.5.0.

str

A 0-terminated C string in the native encoding containing the R source code to parse. Must represent a single R expression.

env

The environment in which to evaluate the expression, must be an ENVSXP.

Value and side effects

R_ParseVector

Parses text and returns an EXPRSXP vector of length no longer than n (if n >= 0). The status may be set to one of the following enumeration constants:

PARSE_OK

Parse succeeded.

PARSE_INCOMPLETE

Found an incomplete expression.

PARSE_ERROR

Found a syntax error.

If *status is not PARSE_OK, the parse failed and the return value is R_NilValue.

R_ParseString

Returns the single expression represented by str in its parsed form, which may be a plain R value, a SYMSXP variable name, or a LANGSXP call object. Raises an error if the parse fails, or if the number of R expressions in str is not 1.

R_ParseEvalString

Returns the result of evaluating the single expression from str in the environment env. May result in arbitrary side effects.


Next: , Previous: , Up: Functions   [Index]

R_GetCurrentSrcref

#include <Rinternals.h>
SEXP R_GetCurrentSrcref(int skip);
SEXP R_GetSrcFilename(SEXP srcref);

Arguments

skip

The number of source references to skip when walking the list of contexts. If skip > 0, skips the source references from the top of the context stack. If skip < 0, counts abs(skip) source references from the bottom of the context stack. For example, skip = -1 will give the deepest source reference in the context stack.

srcref

An object of class srcref, or a NILSXP.

Value and side effects

R_GetCurrentSrcref

Returns an object of class srcref corresponding to the given position in the context stack, or R_NilValue if there were too few source references.

R_GetSrcFilename

Returns a length-1 STRSXP containing the file name corresponding to the source reference in srcref, or an "" if no such name could be found.

Versions: These functions appeared in 2.15.1.


R_MakeExternalPtr

#include <Rinternals.h>
SEXP R_MakeExternalPtr(
 void * p, SEXP tag, SEXP prot
);
SEXP R_MakeExternalPtrFn(
 DL_FUNC p, SEXP tag, SEXP prot
);

void * R_ExternalPtrAddr(SEXP s);
DL_FUNC R_ExternalPtrAddrFn(SEXP s);

SEXP R_ExternalPtrTag(SEXP s);
SEXP R_ExternalPtrProtected(SEXP s);

void R_SetExternalPtrAddr(
 SEXP s, void * p
);
void R_SetExternalPtrTag(SEXP s, SEXP tag);
void R_SetExternalPtrProtected(
 SEXP s, SEXP prot
);

void R_ClearExternalPtr(SEXP s);

Arguments

p

An arbitrary C object pointer or a C function pointer cast to DL_FUNC.

tag

An arbitrary R object. By convention, can be used to identify the type of the pointer: allocate a unique and persistent R value and then verify R_ExternalPtrTag(s) == my_type_tag.

prot

An arbitrary R object. By convention, can be used to keep an R object referenced if p is allocated through prot from the R heap.

s

An EXTPTRSXP object.

Value and side effects

R_MakeExternalPtr
R_MakeExternalPtrFn

Allocate and return a new object of type EXTPTRSXP that contains the pointer p and references the R values tag and prot.

Versions: R_MakeExternalPtrFn appeared in 3.4.0.

R_ExternalPtrAddr
R_ExternalPtrAddrFn

Return the p value stored s. No type checking is performed; care must be taken to use the returned pointer with the correct corresponding object type.

Versions: R_ExternalPtrAddrFn appeared in 3.4.0.

R_ExternalPtrTag

Return the tag value referenced by s.

R_ExternalPtrProtected

Return the prot value referenced by s.

R_SetExternalPtrTag

Replace the tag value referenced by s.

R_SetExternalPtrProtected

Replace the prot value referenced by s.

R_SetExternalPtrAddr

Replace the stored pointer with the provided value p.

R_ClearExternalPtr

Set the stored pointer to the null pointer.

In order to prevent resource leaks by ensuring that the destructors are called, register a finalizer on the EXTPTRSXP value using R_RegisterFinalizer.


Next: , Previous: , Up: Functions   [Index]

R_RegisterFinalizer

#include <Rinternals.h>
void R_RegisterCFinalizer(
 SEXP s, R_CFinalizer_t cfun
);
void R_RegisterCFinalizerEx(
 SEXP s, R_CFinalizer_t cfun, Rboolean onexit
);
void R_RegisterFinalizer(
 SEXP s, SEXP fun
);
void R_RegisterFinalizerEx(
 SEXP s, SEXP fun, Rboolean onexit
);

Arguments

s

A reference-semantics R value: ENVSXP or EXTPTRSXP.

cfun

A C function pointer of type void (*R_CFinalizer_t)(SEXP s) which takes the original object s as an argument and performs the necessary actions to release the associated external resources.

fun

An R value of type CLOSXP, BUILTINSXP, or SPECIALSXP. Must accept the original object s as the first argument and perform the necessary actions.

onexit

Whether to call the finalizer during normal R shutdown. If FALSE, the finalizer will only be called when collecting the object in the middle of an R session. Not explicitly freeing memory on exit can speed up the shutdown process, but at the cost of producing Valgrind and LeakSanitizer warnings.

Finalizers for important resources that don’t go away on their own, such as files, should be always registered with onexit = TRUE.

See also: https://web.archive.org/web/20240607194151/https://devblogs.microsoft.com/oldnewthing/20120105-00/?p=8683


Next: , Previous: , Up: Functions   [Index]

R_MakeWeakRef

#include <Rinternals.h>
SEXP R_MakeWeakRef(
 SEXP key, SEXP value, SEXP fin, Rboolean onexit
);
SEXP R_MakeWeakRefC(
 SEXP key, SEXP value,
 R_CFinalizer_t cfin, Rboolean onexit
);
SEXP R_WeakRefKey(SEXP w);
SEXP R_WeakRefValue(SEXP w);
void R_RunWeakRefFinalizer(SEXP w);

Arguments

key

A reference-semantics R value: ENVSXP or EXTPTRSXP.

value

An arbitrary R value.

fin

An R value of type CLOSXP, BUILTINSXP, or SPECIALSXP. Must accept the key object as the first argument. Can also be R_NilValue when no finalization is needed.

cfin

A C function pointer of type void (*R_CFinalizer_t)(SEXP key) which takes the key object as an argument and performs the necessary cleaning up.

onexit

Whether to call the finalizer during normal R shutdown. If FALSE, the finalizer will only be called when collecting the object in the middle of an R session.

w

A WEAKREFSXP object.

Value and side effects

R_MakeWeakRef
R_MakeWeakRefC

Allocates and returns a new object of type WEAKREFSXP.

R_WeakRefKey

Returns the key of the weak reference, or R_NilValue if it had been deemed no longer reachable.

R_WeakRefValue

Returns the value of the weak reference, or R_NilValue if the key had been deemed no longer reachable.

R_RunWeakRefFinalizer

Destroys the weak reference by cleaning its key and value fields and running the finalizer (if set) with the previous value of the key.

The manner in which weak references propagate reachability is different from other R values:

  • Reachability for the key is not propagated.
  • Reachability for the value is only propagated from weak references whose key is reachable from other values.
  • Reachability of the weak reference itself does not matter.

This makes it possible to automatically manage global lists of reference-semantics objects with associated data.

See also: https://homepage.stat.uiowa.edu/~luke/R/weakfinex.html


Next: , Previous: , Up: Functions   [Index]

VECTOR_ELT

#include <Rinternals.h>
SEXP VECTOR_ELT(SEXP x, R_xlen_t i);
SEXP SET_VECTOR_ELT(
 SEXP x, R_xlen_t i, SEXP v
);
const SEXP * VECTOR_PTR_RO(SEXP x);

Arguments

x

An R value of type VECSXP or EXPRSXP.

i

A zero-based index into x.

v

An arbitrary R value.

Value and side effects

VECTOR_ELT

Returns the value at the zero-based position i of the vector x. Raises an error if x is of the wrong type. If i is out of range 0:(XLENGTH(x) - 1), behaviour is undefined.

SET_VECTOR_ELT

Sets the value v at the zero-based position i of the vector x. Raises an error if x of the wrong type or if i is outside the valid range. Returns v.

VECTOR_PTR_RO

Returns a pointer to the beginning of a buffer of SEXP[XLENGTH(x)], which corresponds to the objects comprising x. Modification of x through this pointer is prohibited. If the length of x is zero, behaviour is undefined.

Versions: Appeared in 4.5.0.


Next: , Previous: , Up: Functions   [Index]

REAL

#include <Rinternals.h>
double * REAL(SEXP x);
const double * REAL_RO(SEXP x);
double REAL_ELT(SEXP x, R_xlen_t i);
void SET_REAL_ELT(
 SEXP x, R_xlen_t i, double v
);

int * INTEGER(SEXP x);
const int * INTEGER_RO(SEXP x);
int INTEGER_ELT(SEXP x, R_xlen_t i);
void SET_INTEGER_ELT(
 SEXP x, R_xlen_t i, int v
);

int * LOGICAL(SEXP x);
const int * LOGICAL_RO(SEXP x);
int LOGICAL_ELT(SEXP x, R_xlen_t i);
void SET_LOGICAL_ELT(
 SEXP x, R_xlen_t i, int v
);

Rbyte * RAW(SEXP x);
const Rbyte * RAW_RO(SEXP x);
Rbyte RAW_ELT(SEXP x, R_xlen_t i);
void SET_RAW_ELT(
 SEXP x, R_xlen_t i, Rbyte v
);

Rcomplex * COMPLEX(SEXP x);
const Rcomplex * COMPLEX_RO(SEXP x);
Rcomplex COMPLEX_ELT(SEXP x, R_xlen_t i);
void SET_COMPLEX_ELT(
 SEXP x, R_xlen_t i, Rcomplex v
);

const void * DATAPTR_RO(SEXP x);

Arguments

x

An R value of the corresponding type (in order: REALSXP, INTSXP, LGLSXP, RAWSXP, CPLXSXP).

For DATAPTR_RO, any vector type.

i

A zero-based index into x.

v

A C value of the corresponding type.

Value and side effects

REAL
INTEGER
LOGICAL
RAW
COMPLEX

Returns a pointer to the start of the buffer that contains XLENGTH(x) elements of the corresponding type. If x is an ALTREP object, this will materialize it. Raises an error if x is not of the corresponding type.

Modifications through the pointer affect x itself: care must be taken if it is shared (see MARK_NOT_MUTABLE). If the length of x is 0, behaviour is undefined.

REAL_RO
INTEGER_RO
LOGICAL_RO
RAW_RO
COMPLEX_RO

Same as above, but modification of the contents of x is prohibited.

Versions: Appeared in 3.5.0.

REAL_ELT
INTEGER_ELT
LOGICAL_ELT
RAW_ELT
COMPLEX_ELT

Returns the element of x at the zero-based position i. May avoid materialising an ALTREP object at the cost of one function call per element. If i is out of range 0:(XLENGTH(x)-1), behaviour is undefined.

Versions: Appeared in 3.5.0.

SET_REAL_ELT
SET_INTEGER_ELT
SET_LOGICAL_ELT
SET_RAW_ELT
SET_COMPLEX_ELT

Sets the element of x at the zero-based position i to v (see MARK_NOT_MUTABLE for how to determine whether a potentially shared x is safe to modify). May avoid materialising an ALTREP object at the cost of one function call per replacement. If i is out of range 0:(XLENGTH(x)-1), behaviour is undefined.

Versions: Appeared in 3.5.0.

DATAPTR_RO

Returns a pointer to the start of vector data of x.

Versions: Appeared in 3.5.0.


Next: , Previous: , Up: Functions   [Index]

translateChar

#include <Rinternals.h>
const char * Rf_translateChar(SEXP x);
#ifndef R_NO_REMAP
#define translateChar Rf_translateChar
#endif
const char * Rf_translateCharUTF8(
 SEXP x
);
#ifndef R_NO_REMAP
#define translateCharUTF8 Rf_translateCharUTF8
#endif

Arguments

x

A CHARSXP value.

Value and side effects

Returns a pointer to the 0-terminated C string represented by x, guaranteed to be in the native (translateChar) or UTF-8 (translateCharUTF8) encoding. Raises an R error if the encoding of x is CE_BYTES.

The underlying buffer may be allocated using R_alloc and thus subject to vmaxset memory management.


Next: , Previous: , Up: Functions   [Index]

reEnc

#include <Rinternals.h>
const char * Rf_reEnc(
 const char * x, cetype_t ce_in,
 cetype_t ce_out, int subst
);
#ifndef R_NO_REMAP
#define reEnc Rf_reEnc
#endif

Arguments

x

A 0-terminated C string to convert.

ce_in

The encoding to convert x from, one of CE_NATIVE, CE_UTF8, CE_LATIN1, CE_BYTES, or CE_SYMBOL.

ce_out

The desired encoding of the return value, one of CE_NATIVE, CE_UTF8, CE_LATIN1, CE_BYTES. (Not CE_SYMBOL.)

subst

How to substitute bytes that failed to translate (due to being invalid in the ce_in encoding or unrepresentable in the ce_out encoding): 1 will substitute the hexadecimal codes of the characters in the form "<%02x>"; 2 will substitute ASCII dots "."; any other value will omit output for these bytes.

Value and side effects

Returns a 0-terminated C string in the encoding specified by ce_out. See R_alloc for how to manage the underlying memory of the buffer.


Next: , Previous: , Up: Functions   [Index]

nrows

#include <Rinternals.h>
int Rf_nrows(SEXP s);
#ifndef R_NO_REMAP
#define nrows Rf_nrows
#endif
int Rf_ncols(SEXP s);
#ifndef R_NO_REMAP
#define ncols Rf_ncols
#endif

Arguments

s

A vector or list value that can have the dim attribute.

Value and side effects

nrows

Like NROW(s) in R, returns the first element of the dim attribute if it exists, otherwise returns the length of s.

ncols

Like NCOL(s) in R, returns the second element of the dim attribute if it exists, otherwise returns 1.


Next: , Previous: , Up: Functions   [Index]

R_Calloc

#include <R_ext/RS.h>
#define R_Calloc(n, t) /*...*/
#define R_Realloc(p, n, t) /*...*/
#define R_Free(p) /*...*/
#ifndef STRICT_R_HEADERS
#define Calloc(n, t) /*...*/
#define Realloc(p, n, t) /*...*/
#define Free(p) /*...*/
#endif

Arguments

n

The number of elements of type t to allocate a buffer for, as an expression that can be cast to R_SIZE_T.

t

The type of each element, as a keyword that can be given to the sizeof(t) operator.

p

An lvalue containing the pointer previously returned by R_Calloc or R_Realloc.

Value and side effects

R_Calloc
Calloc

Allocates a buffer of type t[n], safe from size multiplication overflow, zero-initialises it, and returns a pointer to it. If the allocation fails, raises an R error.

R_Realloc
Realloc

If p is a null pointer, allocates a new buffer of size n*sizeof(t) with contents undefined and returns a pointer to it. Otherwise returns a pointer to a buffer of size n*sizeof(t) partially initialised from the previous contents of the buffer pointed to by p. This may or may not resize the buffer in place. After the function returns a new pointer, the original argument p given to the function is no longer safe to use and must be discarded.

If the size multiplication overflows, behaviour is undefined.

If any allocation fails, raises an R error, leaving the allocation pointed to by p unchanged.

R_Free
Free

Deallocates a buffer previously allocated by R_Callor or R_Realloc and sets p to a null pointer.

Since these functions raise R errors on allocation failures, a way to deallocate the managed resources in the current function must be arranged separately. Typically, this involves static memory, a separate destructor function that calls R_Free, and an R-level on.exit.


Next: , Previous: , Up: Functions   [Index]

error

#include <R_ext/Error.h>
NORET void Rf_error(
 const char * format, ...
);
#ifndef R_NO_REMAP
#define error Rf_error
#endif
void Rf_warning(
 const char * format, ...
);
#ifndef R_NO_REMAP
#define warning Rf_warning
#endif

#include <Rinternals.h>
NORET void Rf_errorcall(
 SEXP call, const char * format, ...
);
#ifndef R_NO_REMAP
#define errorcall Rf_errorcall
#endif
void Rf_warningcall(
 SEXP call, const char * format, ...
);
#ifndef R_NO_REMAP
#define warningcall Rf_warningcall
#endif
void Rf_warningcall_immediate(
 SEXP call, const char * format, ...
);
#ifndef R_NO_REMAP
#define warningcall_immediate Rf_warningcall_immediate
#endif

! Fortran wrappers
subroutine rexit(message)
subroutine rwarn(message)

Arguments

format

A format string suitable for the C function vsnprintf.

...

Variable arguments to be interpreted by the format string.

call

An R value of type LANGSXP specifying the call to blame for the error or the warning being raised, or R_NilValue to avoid printing the location of the call.

character*(*) message

A Fortran string with a length of 255 characters or less.

Value and side effects

Rf_error
Rf_errorcall

Formats the message and raises an R error. This is a nonlocal transfer of control; the function does not return. Any resources without finalizers or error handlers set to release them will be leaked.

Rf_warning
Rf_warningcall

Formats the message and raises an R warning. Depending on the value of getOption('warn'), may ignore the warning (< 0), remember the warning and present it after returning from the top-level context (0); print it immediately (1); or convert it into an error (>= 2).

Care must be taken to ensure that no resources will leak if a warning results in a nonlocal control transfer away from the current function.

Rf_warningcall_immediate

Like warningcall above, but signals the warning immediately if getOption('warn') <= 0.

rexit

The Fortran wrapper for error("%s", message). Will produce an additional warning if message is longer than 255 characters.

rwarn

The Fortran wrapper for warning("%s", message). Will produce an additional warning if message is longer than 255 characters.

Versions: Rf_errorcall and Rf_warningcall first declared in Rinternals.h in version 2.3.0.


Next: , Previous: , Up: Functions   [Index]

GetRNGstate

#include <R_ext/Random.h>
void GetRNGstate(void);
void PutRNGstate(void);
double unif_rand(void);
double norm_rand(void);
double exp_rand(void);
double R_unif_index(double dn);

Arguments

dn

The upped limit for the index, not inclusive.

Value and side effects

GetRNGstate

Reads the state of the random number generator from the .Random.seed variable in the global environment, initialising it if needed. This function must be called once per call to a package function before sampling numbers from the distributions using the functions unif_rand, norm_rand, exp_rand, R_unif_index.

PutRNGstate

Saves the internal state of the random number generator into the .Random.seed variable in the global environment. This function must be called after sampling numbers from the distributions before returning from package code back into R.

unif_rand

Returns a number sampled from the standard uniform distribution. The value is in (0, 1), that is, not including either 0 or 1.

norm_rand

Returns a sample from the standard normal distribution, N(0, 1).

exp_rand

Returns a sample from the standard exponential distribution, with density p(x) = exp(-x) for x >= 0.

R_unif_index

Returns an integer index uniformly sampled from 0:(dn-1). If dn <= 0, returns 0.

Versions: Appeared in 3.4.0.


Next: , Previous: , Up: Functions   [Index]

R_sample_kind

#include <R_ext/Random.h>
typedef enum {
    ROUNDING,
    REJECTION
} Sampletype;
Sampletype R_sample_kind(void);

Value and side effects

Returns the current setting used by the R function sample and other methods of discrete uniform generation. ROUNDING is non-uniform on large populations, so should only be used to reproduce previous results.

See also: https://bugs.r-project.org/show_bug.cgi?id=17494


Next: , Previous: , Up: Functions   [Index]

Rprintf

#include <R_ext/Print.h>
void Rprintf(const char * format, ...);
void REprintf(const char * format, ...);
#if defined(R_USE_C99_IN_CXX) || !defined(__cplusplus)
void Rvprintf(
 const char * format, R_VA_LIST arg
);
void REvprintf(
 const char * format, R_VA_LIST arg
);
#endif

Arguments

format

A format string suitable for the C function vsnprintf.

...
arg

The variadic arguments to be interpreted by the format string.

The macro R_VA_LIST expands to either va_list or std::va_list, depending on whether the header is being included by a C or a C++ compiler. The headers stdarg.h or cstdarg are included as necessary. The va_list interface is only available to the C++ compiler if the preprocessor symbol R_USE_C99_IN_CXX is defined or the C++ version is 11 or above.

Value and side effects

Rprintf
Rvprintf

Formats and prints the specified string on R’s standard output stream, which may be a GUI console window.

REprintf
REvprintf

Formats and prints the specified string on R’s standard error stream, which may be different from the standard output stream.


Next: , Previous: , Up: Functions   [Index]

dblepr

subroutine dblepr(label, nchar, ddata, ndata)
subroutine realpr(label, nchar, rdata, ndata)
subroutine intpr (label, nchar, idata, ndata)
! since R-4.0.0:
subroutine labelpr(label, nchar)
subroutine dblepr1(label, nchar, dvar)
subroutine realpr1(label, nchar, rvar)
subroutine intpr1 (label, nchar, ivar)

Arguments

character*(*) label

A character label to be used as the first line of output, up to 255 characters in length.

integer nchar

The number of characters from label to print. Can be -1 to print all of them, or 0 to suppress the first line.

integer ndata

The number of elements to print from ddata, rdata, or idata.

double precision ddata(ndata), dvar
real rdata(ndata), rvar
integer idata(ndata), ivar

The data to print after the first line. Arrays must be of length ndata or more.

These functions are provided for use from Fortran code.

Value and side effects

If nchar != 0, prints the specified number of characters from label on R’s standard output, followed by a newline. Printing more than 255 characters will result in an R warning.

If calling dblepr, realpr, or intpr with ndata > 0, or if calling dblepr1, realpr1, or intpr1, prints the specified ddata/rdata/idata or dvar/rvar/ivar on R’s standard output like R’s default print method does for plain R values.

Versions: Functions labelpr, dblepr1, realpr1, intpr1 appeared in 4.0.0.


Next: , Previous: , Up: Functions   [Index]

rmultinom

#include <Rmath.h>
void Rf_rmultinom(
 int n, double * prob, int K, int * rN
);
#ifndef R_NO_REMAP_RMATH
#define rmultinom Rf_rmultinom
#endif

Arguments

n

The total number of objects in the multinomial experiment, must be at least 0.

prob

Input parameter: an array of length K specifing the probabilities for the classes. Must sum to 1.

K

The number of elements in prob and rN, must be at least 1.

rN

Output parameter: an array of length K to be filled with the numbers of objects distributed into the specified classes.

Value and side effects

Raises warnings if K < 1 or n < 0. Raises an R error if the elements of prob do not sum to 1. Populates the array pointed to by rN with the numbers of objects distributed into the respective classes during the multinomial experiment.


Next: , Previous: , Up: Functions   [Index]

dwilcox

#include <Rmath.h>
double Rf_dwilcox(
 double x, double m, double n, int give_log
);
#ifndef R_NO_REMAP_RMATH
#define dwilcox Rf_dwilcox
#endif
double Rf_pwilcox(
 double x, double m, double n,
 int lower_tail, int give_log
);
#ifndef R_NO_REMAP_RMATH
#define pwilcox Rf_pwilcox
#endif
double Rf_qwilcox(
 double p, double m, double n,
 int lower_tail, int log_p
);
#ifndef R_NO_REMAP_RMATH
#define qwilcox Rf_qwilcox
#endif
double Rf_rwilcox(double m, double n);
#ifndef R_NO_REMAP_RMATH
#define rwilcox Rf_rwilcox
#endif
void wilcox_free(void);

Arguments

x

The values of the Wilcoxon rank sum statistic (which takes values in 0:(m*n)).

m
n

Numbers of observations in the first (m) and second (n) samples.

give_log

If nonzero, return natural logarithms of probabilities instead of probabilities themselves.

lower_tail

If nonzero, probabilities are of P[X <= x]. Otherwise, P[X > x].

p
log_p

If log_p is zero, p is a probability value. For nonzero log_p, p is the natural logarithm of probability instead of just a probability.

Value and side effects

Rf_dwilcox

Returns the value of the Wilcoxon rank sum statistic probability density function.

Rf_pwilcox

Returns the value of the distribution function.

Rf_qwilcox

Returns the value of the quantile function.

Rf_rwilcox

Returns one sample from the distribution with the given parameters. See GetRNGstate for the RNG state management requirements.

wilcox_free

Releases the internal cache allocated by the functions above. This function should be called after calling any of the functions above and before returning to R.

Versions: Prior to 4.2.0, this function was missing from the installed headers and needed to be declared manually (see R_Version).


Next: , Previous: , Up: Functions   [Index]

R_ShowMessage

#include <R_ext/Error.h>
void R_ShowMessage(const char * s);

Arguments

s

The message, as a 0-terminated C string in the native encoding. May contain newlines.

Value and side effects

Brings the message to the user’s attention immediately. Depending on the frontend in use, this may print s on the console or put up a modal GUI message box.


Next: , Previous: , Up: Functions   [Index]

R_CheckUserInterrupt

#include <R_ext/Utils.h>
void R_CheckUserInterrupt(void);
subroutine rchkusr()

Value and side effects

Checks the stack usage (see R_CheckStack). Checks for a pending interrupt previously caused by typing Ctrl+C to send the INT signal (Unix) or pressing the interrupt button (Rgui.exe on Windows, R.app on macOS). If the interrupt flag is set, signals the interrupt condition, which will perform a nonlocal control transfer to the interrupt handler (if set) or to the top level.

This function must be called from long-running loops in order to keep R responsive. Note that with main-thread front-ends (such as Rgui.exe), checking for interrupts involves first processing the pending GUI events and finding out if the interrupt flag must be set, which may take a noticeable amount of time if the function is called too frequently.


Next: , Previous: , Up: Functions   [Index]

R_CheckStack

#include <R_ext/Utils.h>
void R_CheckStack(void);
void R_CheckStack2(R_SIZE_T extra);

Arguments

extra

The desired amount of additional stack memory.

Value and side effects

On systems and front-ends where stack checking is supported, checks whether the current amount of used stack memory plus extra (if using R_CheckStack2) exceeds the system-specific limit set during R startup. If yes, signals an error condition and jumps to the top level without running error handlers.

If not running on the same main thread as R, behaviour is undefined.

These functions must be called at the beginning of recursive functions (R_CheckStack) or prior to allocating variable amounts of stack memory using alloca or C99 variable-length arrays (R_CheckStack2). Without an explicit check, overflowing the stack will at best crash the process.

Versions: R_CheckStack2 appeared in 3.0.0.


Next: , Previous: , Up: Functions   [Index]

Riconv

#include <R_ext/Riconv.h>
void * Riconv_open(
 const char * tocode, const char * fromcode
);
size_t Riconv(
 void * cd, const char ** inbuf, size_t * inbytesleft,
 char ** outbuf, size_t * outbytesleft
);
int Riconv_close(void * cd);

Arguments

tocode
fromcode

The name of the destination (tocode) and source (fromcode) encodings as 0-terminated C strings. An empty string, "", indicates the encoding of the current locale, like CE_NATIVE.

cd

A valid iconv context pointer previously returned by Riconv_open.

inbuf
inbytesleft

The input buffer (*inbuf)[*inbytesleft], containing the bytes in the encoding specified by fromcode.

outbuf
outbytesleft

The output buffer (*outbuf)[*outbytesleft], intended to contain the text from inbuf represented in the encoding tocode.

Value and side effects

Riconv_open

Allocates and returns an encoding conversion context set up to convert between the specified encodings. On a failure to allocate or initialise the context (e.g. due to the conversion from fromcode to tocode not being supported), returns (void*)-1 and sets errno. Does not return a null pointer.

Riconv

Converts as much data as possible, incrementing *inbuf and *outbuf to point to the start of the remaining data and adjusting *inbytesleft and *outbytesleft. Returns the number of characters converted.

On error, returns (size_t)-1 and sets errno to one of the constants: E2BIG (not enough space in outbuf), EILSEQ (could not decode the byte at *inbuf in the fromcode encoding), or EINVAL (the multi-byte sequence at *inbuf is incomplete).

Riconv_close

Deallocates the resources previously allocated by Riconv_open. This function must be called prior to discarding a context pointer in order to avoid resource leaks.


Next: , Previous: , Up: Functions   [Index]

R_ToplevelExec

#include <Rinternals.h>
Rboolean R_ToplevelExec(
 void (*fun)(void *), void * data
);
SEXP R_tryEval(
 SEXP expr, SEXP env, int * ErrorOccurred
);
SEXP R_tryEvalSilent(
 SEXP expr, SEXP env, int * ErrorOccurred
);

Arguments

fun
data

The function and the data it needs, to execute fun(data) in a separate top-level context.

expr
env

The expression and the environment, to execute eval(expr, env) in a separate top-level context. See eval.

ErrorOccurred

An output variable indicating whether an R-level error has occurred during the call.

Value and side effects

R_ToplevelExec

Temporarily sets up a new top-level context and calls fun(data). Existing condition handlers will not be available for the duration of the call. Raising an R-level error or interrupting R will not propagate past the current call.

Returns TRUE if the call completes normally, FALSE if a jump to the top-level context has been performed.

R_tryEval

Like R_ToplevelExec, but calls eval(expr, env). If the call completes normally, returns the result of evaluation and sets *ErrorOccurred to zero. Otherwise returns a null pointer and sets *ErrorOccurred to a nonzero value.

Versions: Appeared in 1.4.0.

R_tryEvalSilent

Like R_tryEval, but suppresses the printing of error messages for the duration of the call.


Next: , Previous: , Up: Functions   [Index]

R_tryCatch

#include <Rinternals.h>
SEXP R_ExecWithCleanup(
 SEXP (*body)(void *), void * bdata,
 void (*cleanfun)(void *), void *cleandata
);

SEXP R_tryCatch(
 SEXP (*body)(void *), void * bdata,
 SEXP conditions,
 SEXP (*handler)(SEXP condition, void * data), void * hdata,
 void (*cleanfun)(void *), void * cleandata
);
SEXP R_tryCatchError(
 SEXP (*body)(void *), void * bdata,
 SEXP (*handler)(SEXP condition, void * data), void * hdata
);

SEXP R_withCallingErrorHandler(
 SEXP (*body)(void *), void * bdata,
 SEXP (*handler)(SEXP condition, void * data), void * hdata
);

Arguments

body
bdata

The function and data to be called as body(bdata) with error handling.

cleanfun
cleandata

The cleanup function and necessary context to be called as cleanfun(cleandata) unconditionally after a successful call or handling the error. May be a null pointer for R_tryCatch or R_tryCatchError.

conditions

A STRSXP vector of condition classes for which the condition handler will be called.

handler
hdata

The condition handler and necessary context to be called as handler(condition, hdata).

Value and side effects

R_ExecWithCleanup

Calls and returns the value of body(bdata). If an R-level error is raised, the function does not return. Sets up an execution context so that whether the call completes successfully or fails with an R-level error, cleanfun(cleandata) is called.

Versions: Appeared in 3.1.0.

R_tryCatch

Calls and returns the value of body(bdata). Sets up error handlers using an R call to tryCatch(...). If a condition of a class included in conditions is raised, tryCatch unwinds the stack, executes handler(condition, hdata) and returns its result.

Versions: Appeared in 3.4.0.

R_tryCatchError

Same as R_tryCatch(body, bdata, PROTECT(mkString("error")), handler, hdata, NULL, NULL).

Versions: Appeared in 3.4.0.

R_withCallingErrorHandler

Calls and returns the value of body(bdata). If an R-level error is signalled, calls handler(condition, hdata) before unwinding the stack. If handler returns, normal error processing is resumed.

Versions: Appeared in 4.0.0.


Next: , Previous: , Up: Functions   [Index]

R_UnwindProtect

#include <Rinternals.h>
SEXP R_MakeUnwindCont(void);
SEXP R_UnwindProtect(
 SEXP (*fun)(void *), void * data,
 void (*cleanfun)(void *, Rboolean jump), void * cleandata,
 SEXP cont
);
NORET void R_ContinueUnwind(SEXP cont);

Arguments

fun
data

The function to be called as fun(data).

cleanfun
cleandata

The cleanup function to be called as cleanfun(cleandata, jump).

cont

The continuation token. Can be either a value previously returned by R_MakeUnwindCont, or a null pointer.

Value and side effects

R_MakeUnwindCont

Allocates and returns a continuation token. Its SEXPTYPE is unspecified; the only valid uses are with functions described here. Like most values in R, it must be protected for the duration of its use.

R_UnwindProtect
R_ContinueUnwind

Calls and returns the value of fun(data). If the call succeeds, calls cleanfun(cleandata, FALSE) before returning. If the call signals an R-level error, calls cleanfun(cleandata, TRUE) before continuing the stack unwinding.

If cont is not a null pointer, cleanfun is allowed to perform nonlocal control transfers of its own, for example, to unwind the C++ stack. The stack unwinding must stop before reaching the frames owned by R (for example, by catching the exception), at which point the code must resume the R-level error processing by calling R_ContinueUnwind(cont).

Versions: Appeared in 3.5.0.


Next: , Previous: , Up: Functions   [Index]

d1mach

! For compatibility with legacy Fortran code, not declared in a header
double precision function d1mach(i)
integer function i1mach(i)

Arguments

i

The number of the constant to return. Must be in 1:5 for d1mach, 1:16 for i1mach.

Value and side effects

d1mach
1

The smallest positive value representable in a C variable of type double. In Fortran, best replaced by the tiny() intrinsic. In C, use the DBL_MIN constant from <limits.h>.

2

The largest finite value representable in a C variable of type double. In Fortran, best replaced by the huge() intrinsic. In C, use the DBL_MAX constant from <limits.h>.

3
4

For a base-B floating-point number with T digits, d1mach(3) is B^(-T) and d1mach(4) is B^(1-T), giving the bounds on relative spacing. For IEEE 754 double precision floating-point numbers required by R, these values are the machine epsilon times 1/2 and 1, respectively. In Fortran, use the epsilon() intrinsic, and the rrspacing(x) intrinsic for a more direct route to relative spacing near a given x. In C, the values can be obtained using the DBL_EPSILON constant from <limits.h>.

5

The base-10 logarithm of the base (radix) of the floating point types. For IEEE 754 binary floating point numbers, this is log10(2). In Fortran, use the radix() intrinsic. In C, use the FLT_RADIX constant from <limits.h>.

i1mach
1
2

The Fortran unit numbers for the standard input and output, respecitvely. Direct I/O via the standard streams is not supported in R packages. See dblepr for printing from Fortran code in R extensions, Rprintf for the C interface. To read from the R console, construct and evaluate a call to the R functions readline or scan.

In Fortran code running outside of R, best replaced by specifying an asterisk * instead of the unit number in the read and write statements, or use iso_fortran_env, only: input_unit, output_unit.

3

The Fortran unit number for the card punch. Not guaranteed to work, even if a card punch is actually connected to the computer running R. Redirected to the standard error stream in practice, see below.

4

The Fortran unit number for the standard error stream. Direct output to the standard streams is not supported in R packages. See REprintf.

5

The number of bits in a C int value. In Fortran, use the bit_size intrinsic. In C, use CHAR_BIT * sizeof(int) from the <limits.h> header.

6

The number of characters per integer storage unit. In Fortran, either use storage_size() together with bit_size(), combine inquire(iolength=sizeof_int) integer_variable with use iso_fortran_env, only: file_storage_size, or use iso_c_binding, only: c_sizeof (which could all mean subtly different things). In C, use sizeof(int).

7

The base (radix) of the C int type, i.e., 2.

8

The number of significant base-2 digits (bits) in a C int value. In Fortran, use the digits() intrinsic. In C, use CHAR_BIT * sizeof(int) - 1, assuming that one bit is effectively reserved for the sign.

9

The largest int value. Best replaced by the huge() intrinsic in Fortran, INT_MAX from <limits.h> in C.

10

The base (radix) of the C floating point type double, i.e., 2. In Fortran, use the radix() intrinsic. In C, use the FLT_RADIX constant from <limits.h>.

11

The number of base-2 digits in the significand of single-precision floating point numbers (IEEE 754 float32). In Fortran, use the digits() intrinsic. In C, use the FLT_MANT_DIG constant from <limits.h>.

12
13

The minimum and maximum exponents for single-precision floating point numbers, respectively. In other words, the smallest and the largest numbers e such that 2^(e-1) is a normalised float. In Fortran, use the minexponent() and maxexponent() intrinsics. In C, use the FLT_MIN_EXP and FLT_MAX_EXP constants from <limits.h>.

14

The number of base-2 digits in the significand of double-precision floating point numbers (IEEE 754 float64). In Fortran, use the digits() intrinsic. In C, use the DBL_MANT_DIG constant from <limits.h>.

15
16

The minimum and maximum exponents for double-precision floating point numbers, respectively. In other words, the smallest and the largest numbers e such that 2^(e-1) is a normalised double. In Fortran, use the minexponent() and maxexponent() intrinsics. In C, use the DBL_MIN_EXP and DBL_MAX_EXP constants from <limits.h>.

See also: http://web.archive.org/web/20230727205025/https://www.netlib.org/slatec/src/d1mach.f, http://web.archive.org/web/20230727212028/https://www.netlib.org/slatec/src/i1mach.f.


Next: , Previous: , Up: Functions   [Index]

R_ExpandFileName

#include <R_ext/Utils.h>
const char * R_ExpandFileName(const char * fn);

Arguments

s

A path to a file.

Value and side effects

If fn does not start with a tilde (~), returns fn. If fn starts with ~name, returns a copy of fn with the substring replaced by the path to the home directory of user name. If name is an empty string, uses the home directory of the current user. If a lookup of the home directory fails, returns fn. The precise meaning of “home directory” is system-specific.

The return value points to a static buffer that may be overwritten by a subsequent call to R_ExpandFileName. It must not be deallocated by a call to free or otherwise.


Next: , Previous: , Up: Functions   [Index]

R_tmpnam

#include <R_ext/Utils.h>
char * R_tmpnam2(
 const char * prefix, const char * tempdir, const char * fileext
);
char * R_tmpnam(
 const char * prefix, const char * tempdir
);
void R_free_tmpnam(char * name);

Arguments

prefix

The non-random prefix of the desired name of the file. A null pointer is understood to mean an empty string.

tempdir

The directory in which a name for the temp file must be created.

fileext

The non-random suffix of the desired name of the file. May start with a dot in order to make a file extension. A null pointer means an empty string.

name

A value previously returned by R_tmpnam or R_tmpnam2.

Value and side effects

R_tmpnam2

Allocates, constructs and returns a string consisting of tempdir, followed by the system-specific directory separator, followed by prefix, the random part of the file name, and the fileext. The file pointed to by the returned path will not exist at the time of the call to R_tmpnam2.

Versions: Appeared in 2.14.0.

In order to avoid race conditions, it is recommended to set the flags that guarantee that the file will be created, or the system call will fail, e.g. open(name, O_CREAT | O_EXCL, S_IRUSR | S_IWUSR) or CreateFileA(name, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL).

Raises an R error if the resulting string is too long for a file path, an allocation fails, or if, after a fixed number of tries, all paths tried lead to files that already exist. Does not affect the state of R’s random number generator.

R_tmpnam

Same as R_tmpnam2(prefix, tempdir, "").

Versions: Appeared in 1.6.0.

R_free_tmpnam

Deallocates the buffer holding name. Must be called prior to discarding the pointer to avoid resource leaks.

Versions: Appeared in 4.0.03.


Next: , Previous: , Up: Functions   [Index]

lbfgsb

#include <R_ext/Applic.h>
typedef double (*optimfn)(int n, double * xin, void * ex);
typedef void (*optimgr)(int n, double * xin, double * grad, void * ex);
void vmmin(
 int n, double * x, double * Fmin,
 optimfn fn, optimgr gr, int maxit, int trace,
 int * mask, double abstol, double reltol, int nREPORT,
 void * ex, int * fncount, int * grcount, int * fail
);
void nmmin(
 int n, double * xin, double * xout,
 double * Fmin, optimfn fn, int * fail,
 double abstol, double intol, void * ex,
 double alpha, double beta, double gamma,
 int trace, int * fncount, int maxit
);
void cgmin(
 int n, double * xin, double * xout,
 double * Fmin, optimfn fn, optimgr gr,
 int * fail, double abstol, double intol,
 void * ex, int type, int trace, int * fncount,
 int * grcount, int maxit
);
void lbfgsb(
 int n, int m, double * x, double * l,
 double * u, int * nbd, double * Fmin,
 optimfn fn, optimgr gr, int * fail, void * ex,
 double factr, double pgtol, int * fncount,
 int * grcount, int maxit, char * msg,
 int trace, int nREPORT
);
void samin(
 int n, double * x, double * Fmin, optimfn fn,
 int maxit, int tmax, double ti, int trace,
 void * ex
);

Arguments

n

The number of parameters to optimise.

m

The the maximum number of variable metric corrections used to define the L-BFGS approximate Hessian.

xin

The starting point of optimisation.

x

On entry, the starting point of optimisation. On exit, the optimal value found by the function.

xout

The optimal value found by the function.

l
u
nbd

The arrays l[n] and u[n] set the lower and the upper bounds on x, respectively. The array nbd[n] must contain integers in 0:3: 0 if the corresponding parameter is unbounded; 1 if it has a lower bound; 2 if it has both a lower and an upper bound; 3 if it has an upper bound.

Fmin

On exit, the value of the function at the optimal point.

fn

The function to optimise. It must accept the parameters xin[n], the opaque context pointer ex and return the value at the given point.

gr

The gradient of the function to optimise. Given the parameters xin[n] and the opaque context pointer ex, must populate grad[n] with the value of the gradient at the given point.

maxit

The maximal number of iterations.

trace
vmmin
nmmin
cgmin

Will print the progress information if set to a nonzero value. vmmin will print the current value of the function every nREPORT iterations.

lbfgsb
0

No progress printout.

1

Print the current value of the function every nREPORT iterations.

2

Print detailed information at the final iteration.

3

Same as 2, but also print the norm of the projected gradient every nREPORT iterations.

4

Print details of every iteration except “n-vectors”.

5

Same as 4, but also print the changes of active set and more information at the start and the end of iterations.

6

Same as 5, but also print the parameters and the gradient.

Printout is unspecified for other values of trace.

samin

Will print the progress information every trace iterations if set to a positive value; no printout for zero. Must not be set to a negative value.

nREPORT

Report progress information every nREPORT iterations, if enabled with trace. Must be a positive number.

mask

An array of int[n]. A nonzero mask[i] indicates that x[i] is a fixed parameter.

abstol

Termination criterion: stop if fn(n, x, ex) <= abstol.

reltol

Termination criterion: stop if |change in fn()| <= reltol * (|min fn()| + reltol).

intol
nmmin

Termination criterion is determined from the initial value of the function: convtol = intol * (fabs(fn()) + intol). During the iterations, the termination test is the range of the values of the polytope being <= convtol.

cgmin

Termination criterion is determined from the number of function parameters: tol = intol * n * sqrt(intol). During the iterations, the termination test is the conjugate step coefficient being <= tol.

factr

Termination criterion: stop if (change in fn())/max(old fn(), new fn(), 1) <= factr*epsmch, where epsmch is the machine epsilon.

pgtol

Termination criterion: stop if the infinity-norm of the projected gradient is <= pgtol.

tmax

The number of evaluations to take at each temperature.

ti

The starting simulated annealing temperature.

ex

An opaque context pointer passed to fn and gr.

fncount

Output variable, will be populated with the number of calls to fn.

grcount

Output variable, will be populated with the number of calls to gr.

fail
vmmin
cgmin

Set to 0 if the optimisation process converges, 1 otherwise.

nmmin
0

Optimisation converged.

1

Failed to evaluate the function at initial parameters, or exceeded the iteration number limit.

10

Polytope size measure not decreased after trying to shrink it.

lbfgsb
0

Optimisation converged.

1

Exceeded the iteration number limit.

51

Warning: unable to satisfy the convergence conditions.

52

Error in the input arguments.

alpha
beta
gamma

Scaling parameters: reflection factor, contraction factor, expansion factor, respectively. Reasonable defaults are 1.0, 0.5, and 2.0.

type

The type of the conjugate gradients minimiser: 1 for Fletcher-Reeves; 2 for Polak-Ribière; 3 for Beale-Sorenson.

Value and side effects

vmmin

Minimises fn and gr using the variable-metric Broyden-Fletcher-Goldfarb-Shanno algorithm. Memory use is O(n^2). Raises an R-level error if nREPORT <= 0 or if the initial value of the function is not finite.

nmmin

Minimises fn using the Nelder-Mead method. Memory use is O(n^2). Raises an R-level error if the initial value of the function is not finite.

cgmin

Minimises fn and gr using the conjugate gradients method. Memory use is O(n). Raises an R-level error if the initial value of the function is not finite.

lbfgsb

Minimises fn and gr using the limited-memory BFGS method with box constraints. Memory use is O(n*m+m^2). Raises an R-level error if nREPORT <= 0 or if any of the function evaluations resulted in a value that is not finite.

samin

Minimises fn using simulated annealing. Memory use is O(n). Raises an R-level error if trace < 0.


Next: , Previous: , Up: Functions   [Index]

Rdqags

#include <R_ext/Applic.h>
typedef void (*integr_fn)(double *x, int n, void *ex);
void Rdqags(
 integr_fn f, void * ex, double * a, double * b,
 double * epsabs, double * epsrel, double * result,
 double * abserr, int * neval, int * ier,
 int * limit, int * lenw, int * last,
 int * iwork, double * work
);
void Rdqagi(
 integr_fn f, void * ex, double * bound,
 int * inf, double * epsabs, double * epsrel,
 double * result, double * abserr, int * neval,
 int * ier, int * limit, int * lenw, int * last,
 int * iwork, double * work
);

Arguments

f
ex

The function to integrate and its opaque context pointer. Given an array x[n] of function argument values, f must overwrite each element x[i] with the value of the integrand at x[i].

a
b

Input arguments, the bounds of the finite integration interval.

bound
inf

Input arguments. Depending on the value of inf, the bounds of the (semi-)infinite integration interval are:

1

(bound, +Inf)

-1

(-Inf, bound)

2

(-Inf, +Inf); bound ignored

epsabs

Input argument, requested absolute accuracy, i.e., the upper boundary on the absolute difference between *value and the true value of the integral. Must be positive.

epsrel

Input argument, requested relative accuracy, i.e., the upper boundary on the ratio between the absolute error and the modulus of the true value of the integral. Must be >= max(50*DBL_EPSILON, 0.5e-28).

result

Output argument, the approximation of the integral.

abserr

Output argument, the upper bound of the modulus of the absolute integration error.

neval

Output argument, number of evaluations of the integrand. This counts the individual elements of the vectorised calls to f with n > 1.

ier

Output argument indicating the success or possible problems:

0

Normal and reliable termination of the routine. It is assumed that the requested accuracy has been achieved.

1

The maximum number of subdivisions allowed (see limit) has been achieved. Depending on the behaviour of the integrand, increasing limit or splitting the integration interval around singularities or discontinuities may help.

2

Accumulation of roudoff error has been detected. Requested tolerance not achieved. Error may be under-estimated.

3

Detected unacceptably bad behaviour of the integrand.

4

The algorithm does not converge. Requested tolerance cannot be achieved.

5

The integral is probably divergent, or slowly convergent.

6

Invalid input arguments: *epsabs <= 0, *epsrel < max(50 * DBL_EPSILON, 0.5e-28), *limit < 1, or *lenw < *limit * 4.

last

Output argument: the number of subintervals produced in the subdivision process.

iwork
limit

The iwork[*limit] buffer will be used as necessary storage, with limit determining the maximal number of subintervals used.

If *last <= (*limit/2 + 2), let k = *last; otherwise let k = *limit + 1 - *last. On exit, the first k elements of iwork contain 1-based indices into work, so that work[(*limit)*3 + iwork[0] - 1], …, work[(*limit)*3 + iwork[k-1] - 1] form a decreasing sequence of error estimates over the subintervals.

work
lenw

The work[*lenw] buffer will be used as necessary storage, with lenw determining the maximal number of subintervals used. *lenw must be at least *limit * 4.

On exit, work[0], …, work[*last - 1] contain the left end points of the subintervals in the partition of the integration range, and work[*limit], …, work[*limit + *last - 1] contain the right end points. work[*limit * 2], …, work[*limit * 2 + *last - 1] contain the integral approximations over the subintervals, and work[*limit * 3], …, work[*limit * 3 + *last - 1] contain the error estimates.

Value and side effects

Rdqags

Integrates f from a to b, populating the output arguments.

Rdqagi

Integrates f over a (semi-)infinite interval, populating the output arguments.

See also: https://web.archive.org/web/20220308020443/https://nines.cs.kuleuven.be/software/QUADPACK/


Next: , Previous: , Up: Functions   [Index]

onintr

#include <R_ext/GraphicsEngine.h>
void Rf_onintr(void);

Value and side effects

If the interrupts are currently suspended, sets the flag that an interrupt is pending and returns.

If the interrupts are not suspended, signals an interrupt condition, allowing a calling handler to invoke an automatically-created resume restart and return from onintr. If the condition is not handled, jumps to the top level like from an unhandled R-level error.


Next: , Previous: , Up: Functions   [Index]

R_strtod

#include <R_ext/Utils.h>
double R_atof(const char * str);
double R_strtod(const char * str, char ** endptr);

Arguments

str

A 0-terminated C string containing a decimal or a hexadecimal number optionally preceded by whitespace. The number may optionally start with the sign, ‘-’ or ‘+’.

A decimal number consists of ASCII digits ‘0’...‘9’, possibly containing the radix character, optionally followed by the decimal exponent, which is ‘e’ (either case), followed by an optional sign, followed by a whole decimal number indicationg a power of ten. For example, +15.e-1 = (1 * 10^1 + 5 * 10^0) * 10^-1 = 1.5.

A hexadecimal number consists of ‘0x’ (case-insensitively), followed by a hexadecimal number entered using ASCII characters ‘0’...‘9’, ‘a’...‘f’ (either case). If the number contains the radix character, it must be followed by binary exponent, which is ‘p’ (either case) followed by an optional sign, followed by a whole decimal number indicating a power of two. This is unlike the C standard behaviour, which makes both of them optional. For example, +0x.18p+4 = (1 * 16^-1 + 8 * 16^-2) * 2^4 = 1.5.

The radix character (“decimal separator”) must be an ASCII dot, ‘.’.

Special strings ‘NaN’, ‘infinity’ and ‘Inf’ are also recognised as numbers, case-insensitively.

end

Optional argument. If not null, will be set to the location after the last processed character.

Value and side effects

Returns the parsed number, optionally storing the pointer past the end of the converted part of the string in endptr. Unlike the C functions atof and strtod, if no conversion is performed, returns NA_REAL, not 0.

Return value is unspecified for hexadecimal fractions with a radix character but no binary exponent4.

Versions: Appeared in 2.7.0.


Next: , Previous: , Up: Functions   [Index]

R_orderVector

#include <Rinternals.h>
void R_orderVector (
 int * indx, int n, SEXP arglist, Rboolean nalast, Rboolean decreasing
);
void R_orderVector1(
 int * indx, int n, SEXP x,       Rboolean nalast, Rboolean decreasing
);

Arguments

indx
n

Output buffer indx[n], will be filled with 0-based indices (in [0, n-1]) that permute the arguments to be sorted.

arglist

A pairlist (see isList, most likely LISTSXP) containing vectors of potentially different types LGLSXP, INTSXP, REALSXP, STRSXP, CPLXSXP, all of length n.

x

A vector of type LGLSXP, INTSXP, REALSXP, STRSXP, CPLXSXP and length n.

nalast

Whether to sort missing values last (TRUE) or first (FALSE).

decreasing

Whether to sort in decreasing order, must be either TRUE or FALSE.

Value and side effects

Populates indx[n] with a permutation sorting the input arguments. Complex vectors are sorted by using the imaginary parts to resolve ties in the real parts of the elements. Behaviour is undefined if any of the input vectors has length less than n.


Next: , Previous: , Up: Functions   [Index]

R_isort

#include <R_ext/Utils.h>
void R_isort(     int * x, int n);
void R_rsort(  double * x, int n);
void R_csort(Rcomplex * x, int n);

void rsort_with_index(double * x, int * indx, int n);
void Rf_revsort(      double * x, int * indx, int n);
#ifndef R_NO_REMAP
#define revsort Rf_revsort
#endif

Arguments

x
n

The buffer x[n] to be sorted.

indx

The buffer indx[n] to which the same permutation will be applied as to x[n].

Value and side effects

R_isort
R_rsort
R_csort

Sorts the values in x[n] in the increasing order. Complex vectors are sorted by using the imaginary parts to resolve ties in the real parts of the elements. NAs are sorted last.

rsort_with_index

In addition to sorting x[n] like R_rsort, permutes the elements of indx[n] in the same manner.

Rf_revsort

Sorts x[n] in the decreasing order without handling NAs and permutes the elements of indx[n] in the same manner.


Next: , Previous: , Up: Functions   [Index]

iPsort

#include <R_ext/Utils.h>
void Rf_iPsort(     int * x, int n, int k);
#ifndef R_NO_REMAP
#define iPsort Rf_iPsort
#endif
void Rf_rPsort(  double * x, int n, int k);
#ifndef R_NO_REMAP
#define rPsort Rf_rPsort
#endif
void Rf_cPsort(Rcomplex * x, int n, int k);
#ifndef R_NO_REMAP
#define cPsort Rf_cPsort
#endif

Arguments

x
n

The buffer x[n] to perform the partial sorting of.

k

The 0-based index into n specifying the basis of the partial sort.

Value and side effects

Permutes the elements of x[n] so that the values smaller than the value originally at x[k] are positioned at smaller indices and the ones larger are positioned at larger indices (likely moving x[k] as well). NAs are sorted last. Behaviour is undefined if k is not in range [0, n-1].


Next: , Previous: , Up: Functions   [Index]

R_qsort

#include <R_ext/Utils.h>
void R_qsort_I(double * v, int * indx, int i, int j);
void R_qsort_int_I(int * v, int * indx, int i, int j);
void R_qsort(double * v, size_t i, size_t j);
void R_qsort_int(int * v, size_t i, size_t j);

! Fortran interface:
subroutine qsort3(x, ii, jj)
subroutine qsort4(x, indx, ii, jj)

Arguments

v
i
j

The buffer v[i:j] to sort, using 1-based indices.

double precision x
integer ii
integer jj

The buffer x(ii:jj) to sort, using 1-based indices.

idx

The buffer indx[i:j] to permute the same way as v (or x).

Value and side effects

Permutes the entries of v[i:j] or x(ii:jj) (and indx at the same indices if applicable) the same way, sorting the contents of v. Indices other than i:j, 1-based, inclusive are not accessed in either array.


Next: , Previous: , Up: Functions   [Index]

UNIMPLEMENTED

#include <R_ext/Error.h>
NORET void UNIMPLEMENTED(const char * s);

Arguments

s

A 0-terminated C string naming the function.

Value and side effects

Raises an R error with the translated error message “unimplemented feature in s”.


Next: , Previous: , Up: Functions   [Index]

R_gc

#include <R_ext/Memory.h>
void R_gc(void);

Value and side effects

If the garbage collector is enabled, performs a full garbage collection. Otherwise, schedules a full garbage collection for the next time it can run.


Previous: , Up: Functions   [Index]

R_malloc_gc

#include <R_ext/Memory.h>
void * R_malloc_gc(size_t n);
void * R_calloc_gc(size_t n, size_t s);
void * R_realloc_gc(void * p, size_t n);

Arguments

n
s

For R_malloc_gc and R_realloc_gc, n is the size of the buffer to allocate. For R_calloc_gc, n*s, safe from multiplication overflow, is the size of the buffer to allocate.

p

The pointer to reallocate.

Value and side effects

These functions call the corresponding standard C library function (malloc / calloc / realloc) and check the return value. A non-null pointer is returned immediately. If the allocation failed, they perform a garbage collection, retry once, and return the resulting pointer.


Next: , Previous: , Up: Introduction   [Index]

4 Experimental functions


R_chk_calloc

#include <R_ext/RS.h>
void * R_chk_calloc(R_SIZE_T nelem, R_SIZE_T elsize);
void * R_chk_realloc(void * ptr, R_SIZE_T size);
void R_chk_free(void * ptr);

Arguments

nelem

The number of elements of size elsize to allocate a buffer for.

elsize

The size of each element.

ptr

A pointer previously returned by R_chk_calloc or R_chk_realloc.

Value and side effects

R_chk_calloc

This is the function underlying the R_Calloc macro. See R_Calloc.

R_realloc

This is the function underlying the R_Realloc macro. See R_Realloc.

R_Free

This is the function underlying the R_Free macro. See R_Free.


R_Serialize

#include <Rinternals.h>
typedef void * R_pstream_data_t;
typedef enum {
    R_pstream_any_format,
    R_pstream_ascii_format,
    R_pstream_binary_format,
    R_pstream_xdr_format,
    R_pstream_asciihex_format
} R_pstream_format_t;

typedef struct R_outpstream_st * R_outpstream_t;
typedef struct R_inpstream_st * R_inpstream_t;

void R_InitInPStream(
 R_inpstream_t istream, R_pstream_data_t data,
 R_pstream_format_t type,
 int (*inchar)(R_inpstream_t stream),
 void (*inbytes)(R_inpstream_t stream, void * buf, int length),
 SEXP (*phook)(SEXP, SEXP), SEXP pdata
);
void R_InitOutPStream(
 R_outpstream_t ostream, R_pstream_data_t data,
 R_pstream_format_t type, int version,
 void (*outchar)(R_outpstream_t stream, int chr),
 void (*outbytes)(R_outpstream_t stream, void * buf, int length),
 SEXP (*phook)(SEXP, SEXP), SEXP pdata
);

void R_InitFileInPStream(
 R_inpstream_t istream, FILE * fp,
 R_pstream_format_t type,
 SEXP (*phook)(SEXP pref, SEXP pdata), SEXP pdata
);
void R_InitFileOutPStream(
 R_outpstream_t ostream, FILE * fp,
 R_pstream_format_t type, int version,
 SEXP (*phook)(SEXP ref, SEXP pdata), SEXP pdata
);

void R_Serialize(SEXP s, R_outpstream_t stream);
SEXP R_Unserialize(R_inpstream_t stream);

Arguments

istream

A pointer to a caller-allocated struct R_inpstream_st. The header file provides a definition of the structure, but its contents are an implementation detail. For R_Unserialize, the structure must be previously initialised.

ostream

A pointer to a caller-allocated struct R_outpstream_st. The header file provides a definition of the structure, but its contents are an implementation detail. For R_Serialize, the structure must be previously initialised.

data

The context pointer for the user-provided functions inchar, inbytes, outchar, outbytes. Inside the callbacks, can be accessed as stream->data.

type

Set the output format for serialization or limit the input format for unserialization.

R_pstream_any_format

For unserialization: accept any of the formats described below. Invalid for serialization.

R_pstream_ascii_format
R_pstream_asciihex_format

Represents R data using 7-bit ASCII: strings are written using backslash-escapes, raw bytes and integers are written in hexadecimal representation. In R_pstream_ascii_format, floating-point numbers are written out using the decimal %.16g format, which may not round-trip exactly, especially between platforms. In R_pstream_asciihex_format, floating-point numbers are written out using the hexadecimal %a format, which more directly corresponds to the binary representation of IEEE 754 float64 numbers. Not very fast and doesn’t compress as well as binary formats.

R_pstream_binary_format

Stores the in-memory representation of primitive R types. The fastest option; doesn’t have a guaranteed byte order.

R_pstream_xdr_format

Stores the primitive R types in an XDR-like format where every multi-byte value (such as 8-byte float64 numbers) is stored in the big-endian order.

version

The version of the format to use, must be 2 or 3. Format version 3 requires at least R version 3.5.0 to unserialize. Format version 2 does not specify the native encoding, so CE_NATIVE strings are not guaranteed to unserialize in a valid manner. Additionally, serializing in format version 2 will materialize ALTREP objects. The minimum R version requirement is 2.3.0.

inchar

Like the C fgets function, must read a single byte from the serialized stream and return it as an int, or return EOF.

inbytes

Must fully populate the buffer buf[length] with the next requested portion of the serialized stream, or signal an R-level error if that’s impossible.

outchar

Called for individual bytes of the output serialization stream represented as ints, like the C function fputc. May signal an R-level error on failure.

outbytes

Called with buf[length] populated with a portion of the output serialization stream. May signal an R-level error on failure.

phook
pdata

On serialization, the phook function will be called for objects of type WEAKREFSXP, EXTPTRSXP, and some objects of type ENVSXP (skipping the predefined and package/namespace environments). The first argument is the object in question; the second argument is the pdata context object. Must either return R_NilValue in order to serialize the object as normal, or a STRSXP vector of positive length, which will be serialized instead of the reference object.

On unserialization, this function will be called for every custom-serialized object, with the first argument being the previously produced STRSXP vector and the second argument being the pdata context object. The return value will be used instead of the STRSXP representation.

phook can be a null pointer in order to disable this behaviour.

fp

The C standard input/output file pointer to serialize the object into or read the serialized data stream from. If used with a C++ compiler, the type of this argument is std::FILE* instead.

Value and side effects

R_InitInPStream
R_InitFileInPStream

Prepares the context object pointed to by istream for a subsequent call to R_Unserialize using either user-provided callbacks or the standard C input/output subsystem.

R_InitOutPStream
R_InitFileOutPStream

Prepares the context object pointed to by ostream for a subsequent call to R_Serialize using either user-provided callbacks or the standard C input/output subsystem.

R_Serialize

Generates a byte representation of s according to the settings in ostream and provides it to the callbacks specified by the initialization function. Invalid serialization settings provided at the initialization stage may result in an R-level error from this function.

R_Unserialize

Calls the callbacks provided by the initialization function, decodes an R object represented by the returned byte stream and returns it. Invalid unserialization settings provided at the initialization stage may result in an R-level error from this function.

This function must not be used with untrusted sources of data. The problem is not limited to yet-undiscovered vulnerabilities in the serialization format parser, since valid R objects can contain code and therefore are capable of arbitrary behaviour, including reading and writing user data and sending it over the network.


Next: , Previous: , Up: Experimental functions   [Index]

allocS4Object

#include <Rinternals.h>
SEXP Rf_allocS4Object(void);
#ifndef R_NO_REMAP
#define allocS4Object Rf_allocS4Object
#endif

Value and side effects

Allocates and returns an R value of type OBJSXP with the S4 bit set.


asS4

#include <Rinternals.h>
SEXP Rf_asS4(
 SEXP s, Rboolean flag, int complete
);
#ifndef R_NO_REMAP
#define asS4 Rf_asS4
#endif

Arguments

s

The source object, any R value.

flag

TRUE if s must be converted into an S4 object, FALSE otherwise.

complete

If s has the S4 bit set and flag is FALSE:

0

Return the same value as s but with the S4 bit unset

1

Only return the data slot of s if it’s neither a NILSXP nor has the S4 bit set.

otherwise

Like the complete = 1 case above, but if the condition is not met, return s unchanged.

Value and side effects

Converts between S4 and non-S4 objects. If the S4 bit of s matches flag, returns s unchanged. Otherwise works on a shallow duplicate (see shallow_duplicate) of s if it is MAYBE_SHARED (see MAYBE_SHARED). When converting a non-S4 object to an S4 object, sets the S4 bit and returns the result. Otherwise acts depending on the complete argument. Signals an R error if complete = 1 and the condition is not met.


Next: , Previous: , Up: Experimental functions   [Index]

R_check_class_etc

#include <Rinternals.h>
int R_check_class_etc(
 SEXP x, const char ** valid
);

Arguments

x

An S4 object.

valid

An array of 0-terminated C strings naming S4 classes. Must be terminated by an empty string, "".

Value and side effects

Returns the 0-based index i of the class in valid that would have satisfied the R expression is(x, valid[i]). If no classes match, returns -1.

Versions: Prior to 4.5.0, behaviour for values without the object bit set was unspecified5.


R_getClassDef

#include <Rinternals.h>
SEXP R_do_MAKE_CLASS(const char * what);
SEXP R_getClassDef(const char *what);

Arguments

what

The name of an S4 class as a 0-terminated C string.

Value and side effects

R_do_MAKE_CLASS

Calls methods::getClass and returns the S4 class definition object for class what. If no class defition was found, signals an R-level error.

R_getClassDef

Calls methods::getClassDef and returns the S4 class definition object for class what. If not class defition was found, returns R_NilValue.


R_do_new_object

#include <Rinternals.h>
SEXP R_do_new_object(SEXP class_def);

Arguments

class_def

The S4 class definition object previously returned by methods::getClassDef. See R_getClassDef.

Value and side effects

Creates and returns a new S4 object of the given class.


R_do_slot

#include <Rinternals.h>
int R_has_slot(
 SEXP obj, SEXP name
);
SEXP R_do_slot(
 SEXP obj, SEXP name
);
SEXP R_do_slot_assign(
 SEXP obj, SEXP name, SEXP value
);

Arguments

obj

An S4 object.

name

The name of the slot. Must be either a SYMSXP or a 1-element STRSXP vector.

value

The desired value of the slot name. Unlike the attributes, can be a NILSXP.

Value and side effects

R_has_slot

Returns a nonzero value if obj has a slot named name, otherwise, a zero.

Versions: Appeared in 2.7.0.

R_do_slot

Returns the equivalent of R expression obj@name. If the slot named name does not exist, signals an R-level error.

R_do_slot_assign

Sets the attribute named name to value on the object obj and returns the new object which may or may not differ from obj.

In particular, when setting the .Data attribute, the value will be allocated anew and must be protected and used in place of the original.


Next: , Previous: , Up: Experimental functions   [Index]

StringBlank

#include <Rinternals.h>
Rboolean Rf_StringBlank(SEXP x);
#ifndef R_NO_REMAP
#define StringBlank Rf_StringBlank
#endif

#include <R_ext/Utils.h>
Rboolean Rf_StringTrue(const char * name);
#define StringTrue Rf_StringTrue
Rboolean Rf_StringFalse(const char * name);
#define StringFalse Rf_StringFalse
Rboolean Rf_isBlankString(const char * name);
#define isBlankString Rf_isBlankString

Arguments

x

A value of type NILSXP or CHARSXP.

name

A 0-terminated C string in the encoding of the current locale.

Value and side effects

Rf_StringBlank

Returns TRUE if x is a NILSXP or a zero-length CHARSXP; otherwise returns FALSE.

Rf_StringTrue

Returns TRUE if name will be interpreted by R as a “truthy” string, e.g., as.character(name) would return TRUE. Otherwise returns FALSE.

Rf_StringFalse

Returns TRUE if name will be interpreted by R as a “falsy” string, e.g., as.character(name) would return FALSE. Otherwise returns FALSE.

Rf_isBlankString

Returns TRUE if name is empty or only consists of “blank” characters, such as spaces, newlines, horizontal or vertical tabs, or form feeds. The precise definition of “blank” depends on the current locale: it is either the C function iswspace (for multi-byte locale encodings), or isspace. Returns FALSE if it finds a non-blank character.


Next: , Previous: , Up: Experimental functions   [Index]

IS_LONG_VEC

#include <Rinternals.h>
int IS_LONG_VEC(SEXP x);

Arguments

x

An R value of vector type (see XLENGTH).

Value and side effects

Returns a nonzero value of x is longer than R_LEN_T_MAX, i.e., LENGTH(x) would signal an error.

Versions: Appeared in 3.0.0.


Next: , Previous: , Up: Experimental functions   [Index]

IS_SCALAR

#include <Rinternals.h>
int IS_SCALAR(SEXP x, int type);

Arguments

x

An arbitrary R value.

type

A SEXPTYPE that corresponds to a vector type (see XLENGTH).

Value and side effects

Returns TRUE if x is of type type and has a length of 1, otherwise FALSE. May raise an error if type is not a vector type.

Versions: Appeared in 3.1.0.


duplicated

#include <Rinternals.h>
R_xlen_t Rf_any_duplicated(
 SEXP x, Rboolean from_last
);
#ifndef R_NO_REMAP
#define any_duplicated Rf_any_duplicated
#endif
R_xlen_t Rf_any_duplicated3(
 SEXP x, SEXP incomp, Rboolean from_last
);
#ifndef R_NO_REMAP
#define any_duplicated3 Rf_any_duplicated3
#endif
SEXP Rf_duplicated(
 SEXP x, Rboolean from_last
);
#ifndef R_NO_REMAP
#define duplicated Rf_duplicated
#endif

Arguments

x

An R vector (see isVector).

incomp

A vector of values convertible to TYPEOF(x) (see coerceVector) that are considered incomparable and therefore will not be marked is duplicated.

from_last

Whether to search for duplicates from the last element of x instead of the first one.

Value and side effects

Rf_any_duplicated
Rf_any_duplicated3

Both functions return the 1-based index of the first encountered element of x that has already been encountered, unless it is also a member of incomp. The return value is 0 if no such element could be found.

Rf_duplicated

Returns an LGLSXP vector of the same length as x. The first appearance (corresponding to the traversal order in from_last) of every item in x is marked with FALSE, and every following occurrence is marked with TRUE.


R_compute_identical

#include <Rinternals.h>
#define IDENT_NUM_AS_BITS /*...*/
#define IDENT_NA_AS_BITS /*...*/
#define IDENT_ATTR_BY_ORDER /*...*/
#define IDENT_USE_BYTECODE /*...*/
#define IDENT_USE_CLOENV /*...*/
#define IDENT_USE_SRCREF /*...*/
#define IDENT_EXTPTR_AS_REF /*...*/
Rboolean R_compute_identical(
 SEXP x, SEXP y, int flags
);

Arguments

x
y

The two R values to compare for being “identical”.

flags

A bitwise combination of the following constants:

IDENT_NUM_AS_BITS

If set, will use bitwise comparison for non-NaN numbers; otherwise, compare them numerically. In particular, bitwise comparison will distinguish the floating point numbers +0 and -0.

IDENT_NA_AS_BITS

If set, will use bitwise comparison for NaN numbers. Otherwise, NAs are identical to each other, but not equal to non-NA NaN’s, which are also identical to each other.

IDENT_ATTR_BY_ORDER

If set, the order in which the attributes are set will be taken into account. Otherwise, the attributes of R values are considered to be sets and therefore orderless.

IDENT_USE_BYTECODE

If set, compare the bytecode bodies of closures. Otherwise, compare their body expressions (see R_ClosureExpr).

IDENT_USE_CLOENV

If set, compare the environment pointers when comparing closures. Otherwise, ignore the environments and only compare the bodies (see above) and the parilists of formals.

IDENT_USE_SRCREF

If set, compare the source references in addition to the bodies and pairlists of formals. Otherwise, ignore the source references.

IDENT_EXTPTR_AS_REF

If set, compare objects of type EXTPTRSXP directly, as in x == y. Otherwise, compare their stored external pointers, as in R_ExternalPtrAddr(x) == R_ExternalPtrAddr(y).

Value and side effects

Tests the values x and y for being “identical”. Precise definition of “identity” is an open question in programming and philosophy, but in R, identical values must have the same type, attributes, and contents, subject to the flags, recursively. For reference-semantics types (ENVSXP, WEAKREFSXP, SYMSXP, NILSXP, see above for EXTPTRSXP), identity is equality of the pointers, not the contents.

The function will not raise any errors for valid x and y. The defaults of the R function identical() correspond to the flags being equal to IDENT_USE_CLOENV.


R_LockBinding

#include <Rinternals.h>
void R_LockBinding(
 SEXP sym, SEXP env
);
Rboolean R_BindingIsLocked(
 SEXP sym, SEXP env
);
void R_unLockBinding(
 SEXP sym, SEXP env
);

Arguments

sym

The name of the binding, a SYMSXP value. Must name an existing binding in env.

env

The environment owning the binding, an ENVSXP. An S4 object based on an environment is also accepted.

Value and side effects

Locking prevents the value of the binding named sym from changing in the environment env until it is unlocked. Unless env is also locked (see R_LockEnvironment), it is still possible to remove the locked binding and then create a new one.

R_LockBinding locks the binding; R_BindingIsLocked returns whether the binding is locked; R_unLockBinding unlocks it again. All three functions will signal an R-level error if sym does not correspond to an existing binding in env. The base environment and the base namespace are handled specially and will work as expected.


R_LockEnvironment

#include <Rinternals.h>
void R_LockEnvironment(
 SEXP env, Rboolean bindings
);
Rboolean R_EnvironmentIsLocked(SEXP env);

Arguments

env

An ENVSXP. An S4 object based on an environment is also accepted.

bindings

Whether to lock all the bindings (see R_LockBinding) before also locking the environment.

Value and side effects

Locking an environment with R_LockEnvironment prevents future additions and removals of bindings to the environment, but does not prevent changes to the existing bindings, unless bindings is set to TRUE. R_EnvironmentIsLocked returns whether env is locked. There is no interface to unlock an environment again.


R_MakeActiveBinding

#include <Rinternals.h>
void R_MakeActiveBinding(
 SEXP sym, SEXP fun, SEXP env
);
SEXP R_ActiveBindingFunction(
 SEXP sym, SEXP env
);
Rboolean R_BindingIsActive(
 SEXP name, SEXP env
);

Arguments

sym

A SYMSXP naming the binding. Must not name an already-existing non-active binding, or a locked binding.

name

A SYMSXP naming the binding. Must correspond to an existing binding in env.

fun

A function: CLOSXP, BUILTINSXP, or SPECIALSXP (see isFunction). Must accept one optional argument.

env

An ENVSXP. An S4 object based on an environment is also accepted.

Value and side effects

R_MakeActiveBinding

Makes it so that reading a variable named sym in the environment env will call fun with no arguments and use the return value as the value of the binding. Assigning to the variable named sym will instead call fun with the value being assigned as the only argument.

R_ActiveBindingFunction

If sym corresponds to an active binding in env, returns its fun. Signals an R-level error otherwise.

R_BindingIsActive

Returns whether sym corresponds to an active binding in env. Signals an R-level error if sym cannot be found in env.


DATAPTR_OR_NULL

#include <Rinternals.h>
const void * DATAPTR_OR_NULL(SEXP x);
const int * LOGICAL_OR_NULL(SEXP x);
const int * INTEGER_OR_NULL(SEXP x);
const double * REAL_OR_NULL(SEXP x);
const Rcomplex * COMPLEX_OR_NULL(SEXP x);
const Rbyte * RAW_OR_NULL(SEXP x);

Arguments

x

An R value of the corresponding type: any vector type for DATAPTR_OR_NULL (see isVector); LGLSXP for LOGICAL_OR_NULL; INTSXP for INTEGER_OR_NULL; REALSXP for REAL_OR_NULL; CPLXSXP for COMPLEX_OR_NULL; RAWSXP for RAW_OR_NULL.

Value and side effects

These functions return a read-only data pointer if one is available (see REAL_RO), but a null pointer if that would have involved materialising an ALTREP object. An R-level error is signalled if x is of the wrong SEXPTYPE.

Versions: Appeared in 3.5.0.


REAL_GET_REGION

#include <Rinternals.h>
R_xlen_t INTEGER_GET_REGION(
 SEXP sx, R_xlen_t i, R_xlen_t n, int * buf
);
R_xlen_t REAL_GET_REGION(
 SEXP sx, R_xlen_t i, R_xlen_t n, double * buf
);
R_xlen_t LOGICAL_GET_REGION(
 SEXP sx, R_xlen_t i, R_xlen_t n, int * buf
);
R_xlen_t COMPLEX_GET_REGION(
 SEXP sx, R_xlen_t i, R_xlen_t n, Rcomplex * buf
);
R_xlen_t RAW_GET_REGION(
 SEXP sx, R_xlen_t i, R_xlen_t n, Rbyte * buf
);

Arguments

sx

An R vector of the corresponding type: INTSXP for INTEGER_GET_REGION, REALSXP for REAL_GET_REGION, LGLSXP for LOGICAL_GET_REGION, CPLXSXP for COMPLEX_GET_REGION, RAWSXP for RAW_GET_REGION.

i

The 0-based index into sx at which to start reading up to n elements.

n

The number of elements to read from sx.

buf

The buffer buf[n] to populate with the contents of sx.

Value and side effects

These functions populate the buffer starting at buf with up to n elements from the vector sx, returning the actual number of elements written. If possible, this will avoid materialising the ALTREP vector. An error is raised if sx is of the wrong type. If i is outside the range 0:(XLENGTH(sx)-1), behaviour is undefined.

Versions: REAL_GET_REGION and INTEGER_GET_REGION ppeared in 3.5.0; LOGICAL_GET_REGION, COMPLEX_GET_REGION, and RAW_GET_REGION appeared in 3.6.0.


REAL_NO_NA

#include <Rinternals.h>
int INTEGER_NO_NA(SEXP x);
int REAL_NO_NA(SEXP x);
int LOGICAL_NO_NA(SEXP x);
int STRING_NO_NA(SEXP x);

Arguments

x

An R vector of the corresponding type: INTSXP for INTEGER_NO_NA, REALSXP for REAL_NO_NA, STRSXP for STRING_NO_NA, LGLSXP for LOGICAL_NO_NA.

Value and side effects

These functions return a nonzero value if it is known that x contains no missing (NA) values. Otherwise the vector may or may not contain missing values. Behaviour is undefined if x is not of the corresponding type.

Versions: INTEGER_NO_NA, REAL_NO_NA, STRING_NO_NA appeared in 3.5.0. LOGICAL_NO_NA appeared in 3.6.0.


Next: , Previous: , Up: Experimental functions   [Index]

REAL_IS_SORTED

#include <Rinternals.h>
enum {
 SORTED_DECR = /*...*/,
 UNKNOWN_SORTEDNESS = /*...*/,
 SORTED_INCR = /*...*/,
};
int INTEGER_IS_SORTED(SEXP x);
int REAL_IS_SORTED(SEXP x);
int STRING_IS_SORTED(SEXP x);

Arguments

x

An R vector of the corresponding type: INTSXP for INTEGER_IS_SORTED, REALSXP for REAL_IS_SORTED, CPLXSXP for COMPLEX_IS_SORTED, RAWSXP for RAW_IS_SORTED.

Value and side effects

These functions return SORTED_DECR if x is known to be sorted in the decreasing order, SORTED_INCR if x is known to be sorted in the increasing order, and UNKNOWN_SORTEDNESS if x may or may not be sorted. Behaviour is undefined if x is not of the corresponding type.

Versions: Appeared in 3.5.0.


ALTREP

#include <Rinternals.h>
int ALTREP(SEXP x);
SEXP ALTREP_CLASS(SEXP ax);
Rboolean R_altrep_inherits(
 SEXP x, R_altrep_class_t class
);

Arguments

x

An arbitrary R value.

ax

An R value for which ALTREP(ax) is nonzero.

class

An ALTREP class pointer.

Value and side effects

ALTREP

Returns a nonzero value if x is a “compact representation” (ALTREP) value. Access to the data pointers of ALTREP values may be problematic and should be replaced with access to individual elements (see REAL_ELT) or vector subregions (see REAL_GET_REGION).

ALTREP_CLASS

Returns the ALTREP class object containing the methods set up for use on ax. The return value is of unspecified SEXPTYPE. Behaviour is undefined if ax is not an ALTREP object.

R_altrep_inherits

Returns a nonzero value if x is an ALTREP value whose class pointer is class.

See also: https://svn.r-project.org/R/branches/ALTREP/ALTREP.html


R_new_altrep

#include <R_ext/Altrep.h>
SEXP R_new_altrep(
 R_altrep_class_t aclass, SEXP data1, SEXP data2
);

#include <Rinternals.h>
SEXP R_altrep_data1(SEXP ax);
SEXP R_altrep_data2(SEXP ax);
void R_set_altrep_data1(SEXP ax, SEXP v);
void R_set_altrep_data2(SEXP ax, SEXP v);

Arguments

aclass

An initialized ALTREP class.

data1
data2

The two instance variables that will belong to the compact-representation value, arbitrary R values.

ax

An R value for which ALTREP(ax) is nonzero.

v

An arbitrary R value.

Value and side effects

R_new_altrep

Allocates, constructs and returns a compact-representation value. It will have the TYPEOF() of the corresponding class and will use the methods in aclass and the instance variables to respond to calls such as XLENGTH().

R_altrep_data1
R_altrep_data2

Returns one of the two ALTREP instance variables belonging to ax. Behaviour is undefined if ax is not an ALTREP object.

R_set_altrep_data1
R_set_altrep_data2

Sets the corresponding ALTREP instance variable of ax to v, sharing it without duplication. Behaviour is undefined if ax is not an ALTREP object.

Versions: Appeared in 3.5.0.

See also: https://svn.r-project.org/R/branches/ALTREP/ALTREP.html


R_set_altrep_..._method

#include <R_ext/Altrep.h>

typedef R_xlen_t (*R_altrep_Length_method_t)(SEXP x);
void R_set_altrep_Length_method(
 R_altrep_class_t cls, R_altrep_Length_method_t fun
);

typedef SEXP (*R_altrep_Duplicate_method_t)(
 SEXP x, Rboolean deep
);
void R_set_altrep_Duplicate_method(
 R_altrep_class_t cls, R_altrep_Duplicate_method_t fun
);

typedef SEXP (*R_altrep_DuplicateEX_method_t)(
 SEXP x, Rboolean deep
);
void R_set_altrep_DuplicateEX_method(
 R_altrep_class_t cls, R_altrep_DuplicateEX_method_t fun
);

typedef SEXP (*R_altrep_Serialized_state_method_t)(SEXP x);
void R_set_altrep_Serialized_state_method(
 R_altrep_class_t cls, R_altrep_Serialized_state_method_t fun
);

typedef SEXP (*R_altrep_Unserialize_method_t)(
 SEXP class, SEXP state
);
void R_set_altrep_Unserialize_method(
 R_altrep_class_t cls, R_altrep_Unserialize_method_t fun
);

typedef SEXP (*R_altrep_UnserializeEX_method_t)(
 SEXP class, SEXP state, SEXP attr,
 int objf, int levs
);
void R_set_altrep_UnserializeEX_method(
 R_altrep_class_t cls, R_altrep_UnserializeEX_method_t fun
);

typedef SEXP (*R_altrep_Coerce_method_t)(SEXP x, int type);
void R_set_altrep_Coerce_method(
 R_altrep_class_t cls, R_altrep_Coerce_method_t fun
);

typedef Rboolean (*R_altrep_Inspect_method_t)(
 SEXP x, int pre, int deep, int pvec,
 void (*inspect_subtree)(SEXP x, int pre, int deep, int pvec)
);
void R_set_altrep_Inspect_method(
 R_altrep_class_t cls, R_altrep_Inspect_method_t fun
);

Arguments

cls

A compact representation vector class object previously returned by R_make_altstring_class, R_make_altinteger_class, R_make_altreal_class, R_make_altlogical_class, R_make_altraw_class, R_make_altcomplex_class, or R_make_altlist_class.

class

The SEXP value corresponding to the ALTREP class definition.

fun

A function pointer of the corresponding type.

x

An ALTREP value.

deep

Set to TRUE if other values possibly contained in x must also be duplicated in the return value instead of being shared by reference.

state

An object previously returned by the Serialized_state method of the class.

attr
objf
levs

Internal fields (attributes, the object bit, the levels fields) of the ALTREP object being unserialized.

type

The desired SEXPTYPE of the return value.

pre

The number of spaces in the Inspect output prefix.

deep

A positive number defines the recursion depth of the Inspect output; 0 for no recursion, -1 for effectively unlimited recursion.

pvec

The number of vector elements to print when Inspecting vector values.

inspect_subtree

The function to call in order to inspect the child elements of x if deep != 0. Will automatically adjust pre (by two) and deep (by one) for the duration of the call.

Value and side effects

R_set_altrep_Length_method
R_set_altrep_Duplicate_method
R_set_altrep_DuplicateEX_method
R_set_altrep_Serialized_state_method
R_set_altrep_Unserialize_method
R_set_altrep_UnserializeEX_method
R_set_altrep_Coerce_method
R_set_altrep_Inspect_method

Sets the function pointer inside the ALTREP class object. Currently, these methods are common to all ALTREP classes. There is no facility for unregistering ALTREP classes, so once a function pointer is set from a package shared library, it must not be unloaded.

R_altrep_Length_method_t

Must return the length of the compact-representation vector, or signal an error. The default method signals an error.

R_altrep_Duplicate_method_t

Must return a copy (see duplicate) of x that can be altered independently of x, ignoring the attributes. R will duplicate and install the attributes by itself.

May return a null pointer, in which case R will produce a materialised copy of the object by itself. The default method returns a null pointer.

R_altrep_DuplicateEX_method_t

Like the Duplicate method above, but must duplicate the attributes in the same manner.

May return a null pointer, in which case R will produce a materialised copy of the object by itself. The default method calls the Duplicate method, duplicates the attributes of x and installs them onto the return value.

R_altrep_Serialized_state_method_t

Must prepare and return a representation of x that can be given to the Unserialize methods below in order to recreate it.

May return a null pointer, making R materialise the object when saving it. The default method returns a null pointer.

R_altrep_Unserialize_method_t

Must construct and return an ALTREP object of the given class given the data previously prepared by the Serialized_state method above.

The default method signals an R-level error.

R_altrep_UnserializeEX_method_t

Like the Unserialize method above, but must also take care of setting the attributes, the levels field and the object bit on the return value. This is likely impossible to implement within the confines of the R API.

The default method calls the Unserialize method, sets the attributes, the object bit, and the levels field, and returns the result.

R_altrep_Coerce_method_t

Must return an R value of SEXPTYPE type containing the result of conversion of x into that type, ignoring the attributes.

May return a null pointer, making R perform the conversion as usual (see coerceVector). The default method returns a null pointer.

R_altrep_Inspect_method_t

This method will be called from .Internal(inspect(...)) after printing the standard SEXP header contents; it can then print (see Rprintf) additional information specific to this ALTREP class. When starting a new line, this method must respect the output indentation pre. Printing the vector elements, if done, should be subject to the recommended vector printing length pvec. The method should call inspect_subtree for child elements, subject to the limits in deep.

If the return value is TRUE, R will consider the value inspected and won’t access its contents; otherwise R will then inspect the contents of x as if it was an ordinary value. Either way, R will then take care of inspecting the attributes of x.

The default method returns FALSE.

Versions: Appeared in 3.5.0.


R_set_altvec_..._method

#include <R_ext/Altrep.h>

typedef void * (*R_altvec_Dataptr_method_t)(
 SEXP x, Rboolean writable
);
void R_set_altvec_Dataptr_method(
 R_altrep_class_t cls, R_altvec_Dataptr_method_t fun
);

typedef const void * (*R_altvec_Dataptr_or_null_method_t)(SEXP x);
void R_set_altvec_Dataptr_or_null_method(
 R_altrep_class_t cls, R_altvec_Dataptr_or_null_method_t fun
);

typedef SEXP (*R_altvec_Extract_subset_method_t)(
 SEXP x, SEXP indx, SEXP call
);
void R_set_altvec_Extract_subset_method(
 R_altrep_class_t cls, R_altvec_Extract_subset_method_t fun
);

Arguments

cls

A compact representation vector class object previously returned by R_make_altstring_class, R_make_altinteger_class, R_make_altreal_class, R_make_altlogical_class, R_make_altraw_class, R_make_altcomplex_class, or R_make_altlist_class.

fun

A function pointer of the corresponding type.

x

An ALTREP value of the corresponding class.

writable

TRUE if the return value may be used to modify x.

indx

A vector of 1-based subscripts to extract from x, of type REALSXP or INTSXP, not necessarily in range [1, XLENGTH(x)].

call

A LANGSXP value for use in error reporting (see errorcall).

Value and side effects

R_set_altvec_Dataptr_method
R_set_altvec_Dataptr_or_null_method
R_set_altvec_Extract_subset_method

Sets the function pointer inside the ALTREP class object. Currently, all ALTREP classes are vector classes. There is no facility for unregistering ALTREP classes, so once a function pointer is set from a package shared library, it must not be unloaded.

R_altvec_Dataptr_method_t

Must return a pointer to the start of the buffer of type corresponding to the SEXPTYPE of x and containing XLENGTH(x) elements (see DATAPTR_RO) corresponding to the contents of x. May signal an R error instead.

The default method always signals an error.

R_altvec_Dataptr_or_null_method_t

Like the Dataptr method above, but the method may return a null pointer to indicate a preference for *_Elt (see REAL_ELT) and *_Get_region (see REAL_GET_REGION) methods instead of full buffer access. The return value will not be used to modify x.

The default method always returns a null pointer.

R_altvec_Extract_subset_method_t

Must allocate and return a new vector containing the result of subsetting, x[indx], following the usual semantics of the [ operator for numeric subscripts. For values outside the range of x, missing values must be returned (R_NilValue for VECSXP lists, 0 for RAWSXP vectors). May also return a null pointer (see above).

The default method always returns a null pointer.

Versions: Appeared in 3.5.0.


R_make_altstring_class

#include <R_ext/Altrep.h>
R_altrep_class_t R_make_altstring_class(
 const char *cname, const char *pname, DllInfo *info
);

typedef SEXP (*R_altstring_Elt_method_t)(SEXP x, R_xlen_t i);
void R_set_altstring_Elt_method(
 R_altrep_class_t cls, R_altstring_Elt_method_t fun
);

typedef void (*R_altstring_Set_elt_method_t)(
 SEXP x, R_xlen_t i, SEXP v
);
void R_set_altstring_Set_elt_method(
 R_altrep_class_t cls, R_altstring_Set_elt_method_t fun
);

typedef int (*R_altstring_Is_sorted_method_t)(SEXP x);
void R_set_altstring_Is_sorted_method(
 R_altrep_class_t cls, R_altstring_Is_sorted_method_t fun
);

typedef int (*R_altstring_No_NA_method_t)(SEXP x);
void R_set_altstring_No_NA_method(
 R_altrep_class_t cls, R_altstring_No_NA_method_t fun
);

Arguments

cname
pname

The name of the ALTREP class and the package owning it, respectively. Together they identify an ALTREP class. It is possible to have multiple classes with the same cname but different pname (and vice versa).

info

An opaque pointer given to the initialization routine of the shared library (see R_registerRoutines).

cls

A class object previously returned by R_make_altstring_class.

fun

A function pointer of the corresponding type.

x

The ALTREP value of the given class.

i

The 0-based index into x in range [0, XLENGTH(x)-1].

v

The CHARSXP value to set into x.

Value and side effects

R_make_altstring_class

Allocates, registers and returns an ALTREP class with the given names.

In addition to the methods given here, compact representation string vectors must implement the common “altrep” methods (see R_set_altrep_..._method) and the common “altvec” methods (see R_set_altvec_..._method).

R_set_altstring_Elt_method
R_set_altstring_Set_elt_method
R_set_altstring_Is_sorted_method
R_set_altstring_No_NA_method

Sets the function pointer inside the ALTREP class object. Behaviour is undefined if cls is not a compact string representation class. There is no facility for unregistering ALTREP classes, so once a function pointer is set from a package shared library, it must not be unloaded.

R_altstring_Elt_method_t

Must return x[i] (for 0-based i) or signal an error. The default method always raises an error.

R_altstring_Set_elt_method_t

Must set x[i] <- v (for 0-based i), even if it’s not compatible with the chosen compact representation, or signal an error. The default method always raises an error.

R_altstring_Is_sorted_method_t

Must return one of the sortedness constants: SORTED_DECR, UNKNOWN_SORTEDNESS, SORTED_INCR. See STRING_IS_SORTED. The default method always returns UNKNOWN_SORTEDNESS.

R_altstring_No_NA_method_t

Must return 1 if x is known not to store any missing values (see STRING_NO_NA), otherwise 0 (including if it’s unknown). The default method always returns 0.

Versions: Appeared in 3.5.0.


R_make_altinteger_class

#include <R_ext/Altrep.h>
R_altrep_class_t R_make_altinteger_class(
 const char *cname, const char *pname, DllInfo *info
);

typedef int (*R_altinteger_Elt_method_t)(
 SEXP x, R_xlen_t i
);
void R_set_altinteger_Elt_method(
 R_altrep_class_t cls, R_altinteger_Elt_method_t fun
);

typedef R_xlen_t (*R_altinteger_Get_region_method_t)(
 SEXP x, R_xlen_t i, R_xlen_t n, int * buf
);
void R_set_altinteger_Get_region_method(
 R_altrep_class_t cls, R_altinteger_Get_region_method_t fun
);

typedef int (*R_altinteger_Is_sorted_method_t)(SEXP x);
void R_set_altinteger_Is_sorted_method(
 R_altrep_class_t cls, R_altinteger_Is_sorted_method_t fun
);

typedef int (*R_altinteger_No_NA_method_t)(SEXP x);
void R_set_altinteger_No_NA_method(
 R_altrep_class_t cls, R_altinteger_No_NA_method_t fun
);

typedef SEXP (*R_altinteger_Sum_method_t)(
 SEXP x, Rboolean narm
);
void R_set_altinteger_Sum_method(
 R_altrep_class_t cls, R_altinteger_Sum_method_t fun
);

typedef SEXP (*R_altinteger_Min_method_t)(
 SEXP x, Rboolean narm
);
void R_set_altinteger_Min_method(
 R_altrep_class_t cls, R_altinteger_Min_method_t fun
);

typedef SEXP (*R_altinteger_Max_method_t)(
 SEXP x, Rboolean narm
);
void R_set_altinteger_Max_method(
 R_altrep_class_t cls, R_altinteger_Max_method_t fun
);

Arguments

cname
pname

The name of the ALTREP class and the package owning it, respectively. Together they identify an ALTREP class. It is possible to have multiple classes with the same cname but different pname (and vice versa).

info

An opaque pointer given to the initialization routine of the shared library (see R_registerRoutines).

cls

A class object previously returned by R_make_altinteger_class.

x

The ALTREP value of the given class.

i

The 0-based index into x in range [0, XLENGTH(x)-1].

n
buf

The buffer buf[n] to populate with the contents of x.

narm

If TRUE, ignore the missing values while computing the summary.

Value and side effects

R_make_altinteger_class

Allocates, registers and returns an ALTREP class with the given names.

In addition to the methods given here, compact representation integer vectors must implement the common “altrep” methods (see R_set_altrep_..._method) and the common “altvec” methods (see R_set_altvec_..._method).

R_set_altinteger_Elt_method
R_set_altinteger_Get_region_method
R_set_altinteger_Is_sorted_method
R_set_altinteger_No_NA_method
R_set_altinteger_Sum_method
R_set_altinteger_Min_method
R_set_altinteger_Max_method

Sets the function pointer inside the ALTREP class object. Behaviour is undefined if cls is not a compact integer vector class. There is no facility for unregistering ALTREP classes, so once a function pointer is set from a package shared library, it must not be unloaded.

R_altinteger_Elt_method_t

Must return x[i] for the 0-based index i. The default method returns INTEGER(x)[i].

R_altinteger_Get_region_method_t

Must copy up to n elements, starting at 0-based index i, into buf[n], and return the number of elements copied. The default method defers to INTEGER_ELT and hence the Elt method above.

R_altinteger_Is_sorted_method_t

Must return one of the sortedness constants: SORTED_DECR, UNKNOWN_SORTEDNESS, SORTED_INCR. See INTEGER_IS_SORTED. The default method always returns UNKNOWN_SORTEDNESS.

R_altinteger_No_NA_method_t

Must return 1 if x is known not to store any missing values (see INTEGER_NO_NA), otherwise 0 (including if it’s unknown). The default method always returns 0.

R_altinteger_Sum_method_t
R_altinteger_Min_method_t
R_altinteger_Max_method_t

Must calculate and return the specified summary of the contents of x, ignoring missing values if narm is TRUE. May return a null pointer, in which case R will compute the summary by accessing the elements of the vector.

Versions: Appeared in 3.5.0.


R_make_altlogical_class

#include <R_ext/Altrep.h>
R_altrep_class_t R_make_altlogical_class(
 const char *cname, const char *pname, DllInfo *info
);

typedef int (*R_altlogical_Elt_method_t)(
 SEXP x, R_xlen_t i
);
void R_set_altlogical_Elt_method(
 R_altrep_class_t cls, R_altlogical_Elt_method_t fun
);

typedef R_xlen_t (*R_altlogical_Get_region_method_t)(
 SEXP x, R_xlen_t i, R_xlen_t n, int * buf
);
void R_set_altlogical_Get_region_method(
 R_altrep_class_t cls, R_altlogical_Get_region_method_t fun
);

typedef int (*R_altlogical_Is_sorted_method_t)(SEXP x);
void R_set_altlogical_Is_sorted_method(
 R_altrep_class_t cls, R_altlogical_Is_sorted_method_t fun
);

typedef int (*R_altlogical_No_NA_method_t)(SEXP x);
void R_set_altlogical_No_NA_method(
 R_altrep_class_t cls, R_altlogical_No_NA_method_t fun
);

typedef SEXP (*R_altlogical_Sum_method_t)(
 SEXP x, Rboolean narm
);
void R_set_altlogical_Sum_method(
 R_altrep_class_t cls, R_altlogical_Sum_method_t fun
);

Arguments

cname
pname

The name of the ALTREP class and the package owning it, respectively. Together they identify an ALTREP class. It is possible to have multiple classes with the same cname but different pname (and vice versa).

info

An opaque pointer given to the initialization routine of the shared library (see R_registerRoutines).

cls

A class object previously returned by R_make_altlogical_class.

x

The ALTREP value of the given class.

i

The 0-based index into x in range [0, XLENGTH(x)-1].

n
buf

The buffer buf[n] to populate with the contents of x.

narm

If TRUE, ignore the missing values while computing the summary.

Value and side effects

R_make_altlogical_class

Allocates, registers and returns an ALTREP class with the given names.

In addition to the methods given here, compact representation integer vectors must implement the common “altrep” methods (see R_set_altrep_..._method) and the common “altvec” methods (see R_set_altvec_..._method).

R_set_altlogical_Elt_method
R_set_altlogical_Get_region_method
R_set_altlogical_Is_sorted_method
R_set_altlogical_No_NA_method
R_set_altlogical_Sum_method

Sets the function pointer inside the ALTREP class object. Behaviour is undefined if cls is not a compact integer vector class. There is no facility for unregistering ALTREP classes, so once a function pointer is set from a package shared library, it must not be unloaded.

R_altlogical_Elt_method_t

Must return x[i] for the 0-based index i. The default method returns LOGICAL(x)[i].

R_altlogical_Get_region_method_t

Must copy up to n elements, starting at 0-based index i, into buf[n], and return the number of elements copied. The default method defers to LOGICAL_ELT and hence the Elt method above.

R_altlogical_Is_sorted_method_t

Must return one of the sortedness constants: SORTED_DECR, UNKNOWN_SORTEDNESS, SORTED_INCR. See INTEGER_IS_SORTED. The default method always returns UNKNOWN_SORTEDNESS.

R_altlogical_No_NA_method_t

Must return 1 if x is known not to store any missing values (see LOGICAL_NO_NA), otherwise 0 (including if it’s unknown). The default method always returns 0.

R_altlogical_Sum_method_t

Must calculate and return the specified summary of the contents of x, ignoring missing values if narm is TRUE. May return a null pointer, in which case R will compute the summary by accessing the elements of the vector.

Versions: Appeared in 3.6.0.


R_make_altreal_class

#include <R_ext/Altrep.h>
R_altrep_class_t R_make_altreal_class(
 const char *cname, const char *pname, DllInfo *info
);

typedef double (*R_altreal_Elt_method_t)(
 SEXP x, R_xlen_t i
);
void R_set_altreal_Elt_method(
 R_altrep_class_t cls, R_altreal_Elt_method_t fun
);

typedef R_xlen_t (*R_altreal_Get_region_method_t)(
 SEXP x, R_xlen_t i, R_xlen_t n, double * buf
);
void R_set_altreal_Get_region_method(
 R_altrep_class_t cls, R_altreal_Get_region_method_t fun
);

typedef int (*R_altreal_Is_sorted_method_t)(SEXP x);
void R_set_altreal_Is_sorted_method(
 R_altrep_class_t cls, R_altreal_Is_sorted_method_t fun
);

typedef int (*R_altreal_No_NA_method_t)(SEXP x);
void R_set_altreal_No_NA_method(
 R_altrep_class_t cls, R_altreal_No_NA_method_t fun
);

typedef SEXP (*R_altreal_Sum_method_t)(
 SEXP x, Rboolean narm
);
void R_set_altreal_Sum_method(
 R_altrep_class_t cls, R_altreal_Sum_method_t fun
);

typedef SEXP (*R_altreal_Min_method_t)(
 SEXP x, Rboolean narm
);
void R_set_altreal_Min_method(
 R_altrep_class_t cls, R_altreal_Min_method_t fun
);

typedef SEXP (*R_altreal_Max_method_t)(
 SEXP x, Rboolean narm
);
void R_set_altreal_Max_method(
 R_altrep_class_t cls, R_altreal_Max_method_t fun
);

Arguments

cname
pname

The name of the ALTREP class and the package owning it, respectively. Together they identify an ALTREP class. It is possible to have multiple classes with the same cname but different pname (and vice versa).

info

An opaque pointer given to the initialization routine of the shared library (see R_registerRoutines).

cls

A class object previously returned by R_make_altreal_class.

x

The ALTREP value of the given class.

i

The 0-based index into x in range [0, XLENGTH(x)-1].

n
buf

The buffer buf[n] to populate with the contents of x.

narm

If TRUE, ignore the missing values while computing the summary.

Value and side effects

R_make_altreal_class

Allocates, registers and returns an ALTREP class with the given names.

In addition to the methods given here, compact representation real vectors must implement the common “altrep” methods (see R_set_altrep_..._method) and the common “altvec” methods (see R_set_altvec_..._method).

R_set_altreal_Elt_method
R_set_altreal_Get_region_method
R_set_altreal_Is_sorted_method
R_set_altreal_No_NA_method
R_set_altreal_Sum_method
R_set_altreal_Min_method
R_set_altreal_Max_method

Sets the function pointer inside the ALTREP class object. Behaviour is undefined if cls is not a compact real vector class. There is no facility for unregistering ALTREP classes, so once a function pointer is set from a package shared library, it must not be unloaded.

R_altreal_Elt_method_t

Must return x[i] for the 0-based index i. The default method returns REAL(x)[i].

R_altreal_Get_region_method_t

Must copy up to n elements, starting at 0-based index i, into buf[n], and return the number of elements copied. The default method defers to REAL_ELT and hence the Elt method above.

R_altreal_Is_sorted_method_t

Must return one of the sortedness constants: SORTED_DECR, UNKNOWN_SORTEDNESS, SORTED_INCR. See REAL_IS_SORTED. The default method always returns UNKNOWN_SORTEDNESS.

R_altreal_No_NA_method_t

Must return 1 if x is known not to store any missing values (see REAL_NO_NA), otherwise 0 (including if it’s unknown). The default method always returns 0.

R_altreal_Sum_method_t
R_altreal_Min_method_t
R_altreal_Max_method_t

Must calculate and return the specified summary of the contents of x, ignoring missing values if narm is TRUE. May return a null pointer, in which case R will compute the summary by accessing the elements of the vector.

Versions: Appeared in 3.5.0.


R_make_altcomplex_class

#include <R_ext/Altrep.h>
R_altrep_class_t R_make_altcomplex_class(
 const char *cname, const char *pname, DllInfo *info
);

typedef Rcomplex (*R_altcomplex_Elt_method_t)(
 SEXP x, R_xlen_t i
);
void R_set_altcomplex_Elt_method(
 R_altrep_class_t cls, R_altcomplex_Elt_method_t fun
);

typedef R_xlen_t (*R_altcomplex_Get_region_method_t)(
 SEXP x, R_xlen_t i, R_xlen_t n, Rcomplex * buf
);
void R_set_altcomplex_Get_region_method(
 R_altrep_class_t cls, R_altcomplex_Get_region_method_t fun
);

Arguments

cname
pname

The name of the ALTREP class and the package owning it, respectively. Together they identify an ALTREP class. It is possible to have multiple classes with the same cname but different pname (and vice versa).

info

An opaque pointer given to the initialization routine of the shared library (see R_registerRoutines).

cls

A class object previously returned by R_make_altcomplex_class.

x

The ALTREP value of the given class.

i

The 0-based index into x in range [0, XLENGTH(x)-1].

n
buf

The buffer buf[n] to populate with the contents of x.

Value and side effects

R_make_altcomplex_class

Allocates, registers and returns an ALTREP class with the given names.

In addition to the methods given here, compact representation complex vectors must implement the common “altrep” methods (see R_set_altrep_..._method) and the common “altvec” methods (see R_set_altvec_..._method).

R_set_altcomplex_Elt_method
R_set_altcomplex_Get_region_method

Sets the function pointer inside the ALTREP class object. Behaviour is undefined if cls is not a compact complex vector class. There is no facility for unregistering ALTREP classes, so once a function pointer is set from a package shared library, it must not be unloaded.

R_altcomplex_Elt_method_t

Must return x[i] for the 0-based index i. The default method returns COMPLEX(x)[i].

R_altcomplex_Get_region_method_t

Must copy up to n elements, starting at 0-based index i, into buf[n], and return the number of elements copied. The default method defers to COMPLEX_ELT and hence the Elt method above.

Versions: Appeared in 3.6.0.


R_make_altraw_class

#include <R_ext/Altrep.h>
R_altrep_class_t R_make_altraw_class(
 const char *cname, const char *pname, DllInfo *info
);

typedef Rbyte (*R_altraw_Elt_method_t)(
 SEXP x, R_xlen_t i
);
void R_set_altraw_Elt_method(
 R_altrep_class_t cls, R_altraw_Elt_method_t fun
);

typedef R_xlen_t (*R_altraw_Get_region_method_t)(
 SEXP x, R_xlen_t i, R_xlen_t n, Rbyte * buf
);
void R_set_altraw_Get_region_method(
 R_altrep_class_t cls, R_altraw_Get_region_method_t fun
);

Arguments

cname
pname

The name of the ALTREP class and the package owning it, respectively. Together they identify an ALTREP class. It is possible to have multiple classes with the same cname but different pname (and vice versa).

info

An opaque pointer given to the initialization routine of the shared library (see R_registerRoutines).

cls

A class object previously returned by R_make_altraw_class.

x

The ALTREP value of the given class.

i

The 0-based index into x in range [0, XLENGTH(x)-1].

n
buf

The buffer buf[n] to populate with the contents of x.

Value and side effects

R_make_altraw_class

Allocates, registers and returns an ALTREP class with the given names.

In addition to the methods given here, compact representation complex vectors must implement the common “altrep” methods (see R_set_altrep_..._method) and the common “altvec” methods (see R_set_altvec_..._method).

R_set_altraw_Elt_method
R_set_altraw_Get_region_method

Sets the function pointer inside the ALTREP class object. Behaviour is undefined if cls is not a compact complex vector class. There is no facility for unregistering ALTREP classes, so once a function pointer is set from a package shared library, it must not be unloaded.

R_altraw_Elt_method_t

Must return x[i] for the 0-based index i. The default method returns RAW(x)[i].

R_altraw_Get_region_method_t

Must copy up to n elements, starting at 0-based index i, into buf[n], and return the number of elements copied. The default method defers to RAW_ELT and hence the Elt method above.

Versions: Appeared in 3.6.0.


R_make_altlist_class

#include <R_ext/Altrep.h>
R_altrep_class_t R_make_altlist_class(
 const char *cname, const char *pname, DllInfo *info
);

typedef SEXP (*R_altlist_Elt_method_t)(
 SEXP x, R_xlen_t i
);
void R_set_altlist_Elt_method(
 R_altrep_class_t cls, R_altlist_Elt_method_t fun
);

typedef void (*R_altlist_Set_elt_method_t)(
 SEXP x, R_xlen_t i, SEXP v
);
void R_set_altlist_Set_elt_method(
 R_altrep_class_t cls, R_altlist_Set_elt_method_t fun
);

Arguments

cname
pname

The name of the ALTREP class and the package owning it, respectively. Together they identify an ALTREP class. It is possible to have multiple classes with the same cname but different pname (and vice versa).

info

An opaque pointer given to the initialization routine of the shared library (see R_registerRoutines).

cls

A class object previously returned by R_make_altlist_class.

x

The ALTREP value of the given class.

i

The 0-based index into x in range [0, XLENGTH(x)-1].

Value and side effects

R_make_altlist_class

Allocates, registers and returns an ALTREP class with the given names.

In addition to the methods given here, compact representation complex vectors must implement the common “altrep” methods (see R_set_altrep_..._method) and the common “altvec” methods (see R_set_altvec_..._method).

R_set_altlist_Elt_method
R_set_altlist_Get_region_method

Sets the function pointer inside the ALTREP class object. Behaviour is undefined if cls is not a compact complex vector class. There is no facility for unregistering ALTREP classes, so once a function pointer is set from a package shared library, it must not be unloaded.

R_altlist_Elt_method_t

Must return x[[i]] for the 0-based index i or raise an error.

R_altlist_Set_elt_method_t

Must set x[[i]] <- v for the 0-based index i, altering x, or raise an error.

Versions: Appeared in 4.3.0.


R_GetX11Image

/* Only available on Unix-like platforms; requires a working X11 device */
#include <R_ext/GetX11Image.h>
Rboolean R_GetX11Image(
 int d, void * pximage, int * pwidth, int * pheight
);

Arguments

d

The number of the open graphical device.

pximage

Output variable, a pointer to a caller-owned pointer-to-XImage. In other words,

#include <X11/Xlib.h>
XImage * image;
void * pximage = &image;
pwidth
pheight

Output variables, the width and the height of the graphics device, respectively.

Value and side effects

If d is not the number of a currently open X11-backed graphics device, returns FALSE. Otherwise calls XGetImage(), populates the output variables with the returned XImage* and the dimensions of the X11 window known to the device, and then returns TRUE. If the returned XImage* is not null, the caller is responsible for eventually deallocating it using XDestroyImage().

Versions: Appeared in 1.7.0.

See also: https://tronche.com/gui/x/xlib/utilities/manipulating-images.html.


nlevels

#include <Rinternals.h>
int Rf_nlevels(SEXP f);
#ifndef R_NO_REMAP
#define nlevels Rf_nlevels
#endif

Arguments

f

An arbitrary R value.

Value and side effects

If f is a factor (see isFactor), returns the length of its levels attribute. Otherwise returns 0.


Next: , Previous: , Up: Experimental functions   [Index]

R_lsInternal3

#include <Rinternals.h>
SEXP R_lsInternal3(
 SEXP env, Rboolean all, Rboolean sorted
);

Arguments

env

An ENVEXP value.

all

Whether to include variable names starting with a dot.

sorted

Whether the return value must be sorted lexicographically.

Value and side effects

Allocates and returns a STRSXP vector containing names of objects in the environment env. The names may include those starting with a dot and may be sorted, depending on the values of all and sorted.

Versions: Appeared in 3.2.0.


copyListMatrix

#include <Rinternals.h>
void Rf_copyListMatrix(
 SEXP destination, SEXP source, Rboolean byrow
);
#ifndef R_NO_REMAP
#define copyListMatrix Rf_copyListMatrix
#endif

Arguments

destination
source

Pairlists (of type LISTSXP or LANGSXP). destination must have a valid two-element dim attribute.

byrow

If TRUE, fill destination with elements row by row, like matrix(byrow = TRUE) in R. Otherwise fill it column by column, like copyVector does for vector types.

Value and side effects

Populates destination with duplicates (see duplicate) of elements of source, overwriting the original contents. If source contains less elements than destination, the rest of the pairlist is filled with NILSXP values.

Behaviour is unspecified if byrow is TRUE and source contains something other than CHARSXP values6.


listAppend

#include <Rinternals.h>
SEXP Rf_listAppend(
 SEXP destination, SEXP source
);
#ifndef R_NO_REMAP
#define listAppend Rf_listAppend
#endif

Arguments

destination
source

Pairlist objects (of type LISTSXP, LANGSXP, or NILSXP).

Value and side effects

Destructively concatenates source at the end of destination, overwriting the tail pair of the latter, and returns destination. The content of destination is shared with source without duplication.

If destination is a NILSXP, returns source.


isVectorizable

#include <Rinternals.h>
Rboolean Rf_isVectorizable(SEXP s);
#ifndef R_NO_REMAP
#define isVectorizable Rf_isVectorizable
#endif

Arguments

s

An arbitrary R value.

Value and side effects

Returns TRUE if s is a VECSXP list or a pairlist (see isPairList), every element of which is an atomic or recursive vector (see isVector) of length no more than one. Also returns TRUE for empty lists of such type. Otherwise returns FALSE.


PairToVectorList

#include <Rinternals.h>
SEXP Rf_PairToVectorList(SEXP p);
#ifndef R_NO_REMAP
#define PairToVectorList Rf_PairToVectorList
#endif
SEXP Rf_VectorToPairList(SEXP v);
#ifndef R_NO_REMAP
#define VectorToPairList Rf_VectorToPairList
#endif

Arguments

p

A pairlist object (see isPairList).

v

A vector list object (see isVectorList).

Value and side effects

Rf_PairToVectorList

Allocates a VECSXP list, populates it with the elements of p, and returns it. If any of the pairs are named, the names attribute of the return value is populated with their TAG() values (empty strings for those of them that are unset). “Most” attributes are copied from p too (see copyMostAttrib).

Rf_VectorToPairList

Allocates a LISTSXP list, populates it with the elements of v, and returns it. TAG() values are set from the non-empty elements of the names attribute of v. Unless the list is empty (and therefore the return value is a NILSXP), “most” attributes are copied from v (see copyMostAttrib).

Signals an R-level error if v is too long (see allocList).


R_existsVarInFrame

#include <Rinternals.h>
Rboolean R_existsVarInFrame(
 SEXP env, SEXP name
);
void R_removeVarFromFrame(
 SEXP name, SEXP env
);

Arguments

env

An ENVSXP value.

name

A SYMSXP value.

Value and side effects

R_existsVarInFrame

Returns TRUE if a binding for name exists in env, otherwise FALSE.

Versions: Appeared in 4.2.0.

R_removeVarFromFrame

If a binding for name exists in env, removes it. Signals an R-level error if env is locked, is the base namespace, the base environment, or the empty environment.

Versions: Appeared in 4.1.0.


R_PackageEnvName

#include <Rinternals.h>
SEXP R_PackageEnvName(SEXP rho);
Rboolean R_IsPackageEnv(SEXP rho);

Arguments

rho

An ENVSXP value.

Value and side effects

R_IsPackageEnv

Returns TRUE if rho is an environment and has a name starting with ‘package:’. Such environments contain the exports from a package, as opposed to package namespaces (see R_FindNamespace).

R_PackageEnvName

If R_IsPackageEnv(rho) is TRUE, returns the STRSXP value containing the name of the environment. Otherwise returns a NILSXP.


R_FindNamespace

#include <Rinternals.h>
SEXP R_FindNamespace(SEXP info);
SEXP R_NamespaceEnvSpec(SEXP rho);
Rboolean R_IsNamespaceEnv(SEXP rho);

Arguments

info

A one-element STRSXP vector containing the name of the package.

rho

An ENVSXP value.

Value and side effects

R_FindNamespace

Returns the namespace environment of the package named info, or signals an R-level error if the package could not be loaded. Behaviour is unspecified if a function named getNamespace shadows the base::getNamespace in the global environment7.

R_NamespaceEnvSpec

If rho is a package namespace, returns its “spec”, which is a character vector; its first element is the name of the namespace and its second element is the version. Otherwise returns a NILSXP.

R_IsNamespaceEnv

Returns TRUE if rho is a namespace environment. Such environments contain all of the results of evaluation of the package source code, not just the exported objects (see R_PackageEnvName).


psmatch

#include <Rinternals.h>
Rboolean Rf_psmatch(
 const char * formal, const char * tag, Rboolean exact
);
#ifndef R_NO_REMAP
#define psmatch Rf_psmatch
#endif
Rboolean Rf_pmatch(
 SEXP formal, SEXP tag, Rboolean exact
);
#ifndef R_NO_REMAP
#define pmatch Rf_pmatch
#endif
SEXP Rf_match(
 SEXP itable, SEXP ix, int nmatch
);
#ifndef R_NO_REMAP
#define match Rf_match
#endif

Arguments

formal
tag

The two strings to compare. For pmatch, can be SYMSXP, CHARSXP, or 1-element STRSXP objects.

exact

Whether the strings formal and tag must match exactly. If FALSE, tag can be a prefix of formal.

itable

A vector of values to find matches against.

ix

A vector of values to find matches for.

nmatch

The value to return for non-matching values.

Value and side effects

psmatch
pmatch

Returns TRUE if tag matches formal, subject to the exact argument; otherwise returns FALSE.

match

Coerces ix and itable to a common SEXPTYPE (see help('<') for the order of type preference). For objects, calls their mtfrm method first. Returns an INTSXP vector of the same length as ix containing the 1-based indices of elements in itable matching the corresponding element in ix. For elements of ix that were not found in itable, nmatch is returned.


Next: , Previous: , Up: Experimental functions   [Index]

charIsUTF8

#include <Rinternals.h>
Rboolean Rf_charIsASCII(SEXP x);
#ifndef R_NO_REMAP
#define charIsASCII Rf_charIsASCII
#endif
Rboolean Rf_charIsUTF8(SEXP x);
#ifndef R_NO_REMAP
#define charIsUTF8 Rf_charIsUTF8
#endif
Rboolean Rf_charIsLatin1(SEXP x);
#ifndef R_NO_REMAP
#define charIsLatin1 Rf_charIsLatin1
#endif

Arguments

x

A CHARSXP object.

Value and side effects

These function return TRUE if x can be considered to be in their respective encodings, FALSE otherwise. This is not as simple as checking getCharCE(x) (see getCharCE): a string can also be in UTF-8 if it’s marked in the native encoding, but the locale encoding is also UTF-8. See translateChar for access to string contents in a guaranteed encoding.

Versions: Appeared in 4.5.0.


Next: , Previous: , Up: Experimental functions   [Index]

R_forceAndCall

#include <Rinternals.h>
SEXP R_forceAndCall(
 SEXP e, int n, SEXP rho
);

Arguments

e

A LANGSXP call.

n

The number of leading arguments to force.

rho

The environment in which to evaluate e, an ENVSXP.

Value and side effects

Evaluates CAR(e) and finds out its type. If the function to call is a SPECIALSXP or a BUILTINSXP, evaluates the call as usual. Otherwise the function must be a CLOSXP: the first n arguments passed to it are evaluated right away (their promises forced). Then the evaluation of the call proceeds normally.

Returns the result of the evaluated call. e is left unchanged.

Versions: Appeared in 3.2.0.


isUnsorted

#include <Rinternals.h>
Rboolean Rf_isUnsorted(
 SEXP x, Rboolean strictly
);
#ifndef R_NO_REMAP
#define isUnsorted Rf_isUnsorted
#endif

Arguments

x

An atomic vector (see isVectorAtomic).

strictly

Whether the comparison must be strict, i.e., not include equality.

Value and side effects

Returns TRUE if x[i] >= x[i+1] (strictly = TRUE) or x[i] > x[i+1] (strictly = FALSE) for any applicable i. Avoids materialising an ALTREP object. Vectors of length less than 2 are considered unsorted.


Rf_ucstoutf8

#include <R_ext/GraphicsEngine.h>

void * Rf_AdobeSymbol2utf8(
 char * out, const char * in,
 size_t nwork, Rboolean usePUA
);
#define AdobeSymbol2utf8 Rf_AdobeSymbol2utf8

int Rf_utf8toAdobeSymbol(
 char * out, const char * in
);
#define utf8toAdobeSymbol Rf_utf82AdobeSymbol

const char * Rf_utf8Toutf8NoPUA(const char * in);
#define utf8Toutf8NoPUA Rf_utf8Toutf8NoPUA

const char * Rf_utf8ToLatin1AdobeSymbol2utf8(
 const char * in, Rboolean usePUA
);
#define utf8ToLatin1AdobeSymbol2utf8 Rf_utf8ToLatin1AdobeSymbol2utf8

size_t Rf_ucstoutf8(char *s, const unsigned int c);

Arguments

out

The output buffer.

in

The input buffer.

nwork

The size of the output buffer. Must be at least 3*strlen(in) + 1.

usePUA

Whether to use Private Use Area code points, expecting a specialised Symbol font, to represent the Adobe Symbol characters unavailable in regular Unicode.

s

Output variable, a buffer with enough space for one Unicode code point represented in UTF-8 followed by the terminating NUL byte.

wc

The number of a Unicode code point.

Value and side effects

Rf_AdobeSymbol2utf8

Converts the Adobe Symbol-encoded text from in into UTF-8 and writes it into out[nwork]. If there is not enough space in the buffer for the first character plus the 0-terminator, behaviour is undefined, but the function is intended to silently truncate the output on a code point boundary. Returns out.

Versions: Appeared in 4.1.0.

Rf_utf8toAdobeSymbol

Performs the inverse operation to Rf_AdobeSymbol2utf8(in, out, in_length, TRUE): reads the UTF-8-encoded text in in and writes its representation in the Adobe Symbol encoding into out, assuming that it uses the PUA characters for Symbol fonts. Returns the length of the string, excluding the final terminator, written into out.

Signals an error if in contains invalid UTF-8 or cannot be represented in the Adobe Symbol encoding.

See vmaxset, for management of the temporary buffer.

Versions: Appeared in 4.1.0.

Rf_utf8Toutf8NoPUA

Reads the result of Rf_AdobeSymbol2utf8(in, out, in_length, TRUE) from in and returns a new UTF-8-encoded string containing the PUA code points replaced by best-fit non-PUA code points. See vmaxset, for management of the returned buffer.

May signal an error if in contains valid UTF-8 that did not originate from Rf_AdobeSymbol2utf8. If in contains invalid UTF-8, behaviour is undefined.

Versions: Appeared in 4.1.0.

Rf_utf8ToLatin1AdobeSymbol2utf8

Converts the contents of in from UTF-8 into Latin-1 using a temporary buffer, substituting ‘.’ for non-representable characters. Interprets the result of the conversion as Adobe Symbol by calling Rf_AdobeSymbol2utf8 on an another temporary buffer and returns the result.

See vmaxset, for management of the temporary buffers.

Versions: Appeared in 4.1.0.

Rf_ucstoutf8

Converts the given Unicode code point into UTF-8 and writes the result into s, followed by a NUL byte. Returns the length of the string (not counting the terminator) written into s.

Will signal an error on conversion problems (see Riconv).

Versions: Appeared in 2.7.0.


5 Indices


Next: , Up: Indices   [Index]

5.1 Headers

Jump to:   R  
Index Entry  Section

R
Rconfig.h: R_INLINE
Rinternals.h: SEXP
Rinternals.h: R_xlen_t
Rinternals.h: R_len_t
Rinternals.h: PROTECT_INDEX
Rinternals.h: SEXPTYPE
Rinternals.h: cetype_t
Rinternals.h: Rbyte
Rinternals.h: R_NilValue
Rinternals.h: R_NamesSymbol
Rinternals.h: XLENGTH
Rinternals.h: PrintValue
Rinternals.h: PROTECT
Rinternals.h: PROTECT_WITH_INDEX
Rinternals.h: R_PreserveInMSet
Rinternals.h: UNPROTECT_PTR
Rinternals.h: R_PreserveObject
Rinternals.h: allocVector
Rinternals.h: xlengthgets
Rinternals.h: copyVector
Rinternals.h: copyMostAttrib
Rinternals.h: isReal
Rinternals.h: isArray
Rinternals.h: coerceVector
Rinternals.h: setAttrib
Rinternals.h: GetArrayDimnames
Rinternals.h: GetColNames
Rinternals.h: GetMatrixDimnames
Rinternals.h: dimnamesgets
Rinternals.h: install
Rinternals.h: mkNamed
Rinternals.h: classgets
Rinternals.h: allocList
Rinternals.h: STRING_ELT
Rinternals.h: mkChar
Rinternals.h: R_mkClosure
Rinternals.h: defineVar
Rinternals.h: R_getVar
Rinternals.h: R_NewEnv
Rinternals.h: asInteger
Rinternals.h: ScalarReal
Rinternals.h: mkString
Rinternals.h: CONS
Rinternals.h: LCONS
Rinternals.h: elt
Rinternals.h: lastElt
Rinternals.h: nthcdr
Rinternals.h: str2type
Rinternals.h: R_ParentEnv
Rinternals.h: inherits
Rinternals.h: topenv
Rinternals.h: GetOption1
Rinternals.h: duplicate
Rinternals.h: ANY_ATTRIB
Rinternals.h: MARK_NOT_MUTABLE
Rinternals.h: SETCADDDR
Rinternals.h: TYPEOF
Rinternals.h: eval
Rinternals.h: findFun
Rinternals.h: R_ParseVector
Rinternals.h: R_GetCurrentSrcref
Rinternals.h: R_MakeExternalPtr
Rinternals.h: R_RegisterFinalizer
Rinternals.h: R_MakeWeakRef
Rinternals.h: VECTOR_ELT
Rinternals.h: REAL
Rinternals.h: translateChar
Rinternals.h: reEnc
Rinternals.h: nrows
Rinternals.h: error
Rinternals.h: R_ToplevelExec
Rinternals.h: R_tryCatch
Rinternals.h: R_UnwindProtect
Rinternals.h: R_orderVector
Rinternals.h: R_Serialize
Rinternals.h: allocS4Object
Rinternals.h: asS4
Rinternals.h: R_check_class_etc
Rinternals.h: R_getClassDef
Rinternals.h: R_do_new_object
Rinternals.h: R_do_slot
Rinternals.h: StringBlank
Rinternals.h: IS_LONG_VEC
Rinternals.h: IS_SCALAR
Rinternals.h: duplicated
Rinternals.h: R_compute_identical
Rinternals.h: R_LockBinding
Rinternals.h: R_LockEnvironment
Rinternals.h: R_MakeActiveBinding
Rinternals.h: DATAPTR_OR_NULL
Rinternals.h: REAL_GET_REGION
Rinternals.h: REAL_NO_NA
Rinternals.h: REAL_IS_SORTED
Rinternals.h: ALTREP
Rinternals.h: R_new_altrep
Rinternals.h: nlevels
Rinternals.h: R_lsInternal3
Rinternals.h: copyListMatrix
Rinternals.h: listAppend
Rinternals.h: isVectorizable
Rinternals.h: PairToVectorList
Rinternals.h: R_existsVarInFrame
Rinternals.h: R_PackageEnvName
Rinternals.h: R_FindNamespace
Rinternals.h: psmatch
Rinternals.h: charIsUTF8
Rinternals.h: R_forceAndCall
Rinternals.h: isUnsorted
Rmath.h: R_PosInf
Rmath.h: M_PI
Rmath.h: rmultinom
Rmath.h: dwilcox
Rversion.h: R_Version
R_ext/Altrep.h: R_new_altrep
R_ext/Altrep.h: R_set_altrep_..._method
R_ext/Altrep.h: R_set_altvec_..._method
R_ext/Altrep.h: R_make_altstring_class
R_ext/Altrep.h: R_make_altinteger_class
R_ext/Altrep.h: R_make_altlogical_class
R_ext/Altrep.h: R_make_altreal_class
R_ext/Altrep.h: R_make_altcomplex_class
R_ext/Altrep.h: R_make_altraw_class
R_ext/Altrep.h: R_make_altlist_class
R_ext/Applic.h: lbfgsb
R_ext/Applic.h: Rdqags
R_ext/Arith.h: R_PosInf
R_ext/Arith.h: ISNAN
R_ext/Boolean.h: Rboolean
R_ext/Constants.h: M_PI
R_ext/Error.h: error
R_ext/Error.h: R_ShowMessage
R_ext/Error.h: UNIMPLEMENTED
R_ext/GetX11Image.h: R_GetX11Image
R_ext/GraphicsEngine.h: onintr
R_ext/GraphicsEngine.h: Rf_ucstoutf8
R_ext/Memory.h: R_alloc
R_ext/Memory.h: R_gc
R_ext/Memory.h: R_malloc_gc
R_ext/Parse.h: R_ParseVector
R_ext/Print.h: Rprintf
R_ext/Random.h: GetRNGstate
R_ext/Random.h: R_sample_kind
R_ext/Rdynload.h: DL_FUNC
R_ext/Rdynload.h: R_registerRoutines
R_ext/Rdynload.h: R_RegisterCCallable
R_ext/Riconv.h: Riconv
R_ext/RS.h: R_Calloc
R_ext/RS.h: R_chk_calloc
R_ext/Utils.h: R_SIZE_T
R_ext/Utils.h: R_CheckUserInterrupt
R_ext/Utils.h: R_CheckStack
R_ext/Utils.h: R_ExpandFileName
R_ext/Utils.h: R_tmpnam
R_ext/Utils.h: R_strtod
R_ext/Utils.h: R_isort
R_ext/Utils.h: iPsort
R_ext/Utils.h: R_qsort
R_ext/Utils.h: StringBlank

Jump to:   R  

Next: , Previous: , Up: Indices   [Index]

5.2 API


5.2.1 Functions

Jump to:   A   B   C   D   E   F   G   I   L   M   N   O   P   Q   R   S   T   U   V   W   X  
Index Entry  Section

A
R_alloc: R_alloc
Rf_alloc3DArray: allocVector
alloc3DArray: allocVector
Rf_allocArray: allocVector
allocArray: allocVector
Rf_allocLang: allocList
allocLang: allocList
R_allocLD: R_alloc
Rf_allocList: allocList
allocList: allocList
Rf_allocMatrix: allocVector
allocMatrix: allocVector
Rf_allocVector: allocVector
allocVector: allocVector
ANY_ATTRIB: ANY_ATTRIB
Rf_asChar: asInteger
asChar: asInteger
Rf_asCharacterFactor: asInteger
asCharacterFactor: asInteger
Rf_asComplex: asInteger
asComplex: asInteger
Rf_asInteger: asInteger
asInteger: asInteger
Rf_asLogical: asInteger
asLogical: asInteger
Rf_asReal: asInteger
asReal: asInteger
R_atof: R_strtod

B
R_BytecodeExpr: R_mkClosure

C
CAAR: SETCADDDR
CAD4R: SETCADDDR
CAD5R: SETCADDDR
CADDDR: SETCADDDR
CADDR: SETCADDDR
CADR: SETCADDDR
R_Calloc: R_Calloc
Calloc: R_Calloc
R_calloc_gc: R_malloc_gc
CAR: SETCADDDR
CDAR: SETCADDDR
CDDDR: SETCADDDR
CDDR: SETCADDDR
CDR: SETCADDDR
cgmin: lbfgsb
CHAR: mkChar
R_CHAR: mkChar
R_CheckStack: R_CheckStack
R_CheckStack2: R_CheckStack
R_CheckUserInterrupt: R_CheckUserInterrupt
Rf_classgets: classgets
classgets: classgets
R_ClearExternalPtr: R_MakeExternalPtr
CLEAR_ATTRIB: ANY_ATTRIB
R_ClosureBody: R_mkClosure
R_ClosureEnv: R_mkClosure
R_ClosureExpr: R_mkClosure
R_ClosureFormals: R_mkClosure
Rf_coerceVector: coerceVector
coerceVector: coerceVector
COMPLEX: REAL
COMPLEX_ELT: REAL
COMPLEX_RO: REAL
Rf_cons: CONS
cons: CONS
CONS: CONS
R_ContinueUnwind: R_UnwindProtect
Rf_copyMatrix: copyVector
copyMatrix: copyVector
Rf_copyMostAttrib: copyMostAttrib
copyMostAttrib: copyMostAttrib
Rf_copyVector: copyVector
copyVector: copyVector
Rf_cPsort: iPsort
cPsort: iPsort
R_csort: R_isort

D
d1mach: d1mach
DATAPTR_RO: REAL
dblepr: dblepr
dblepr1: dblepr
Rf_defineVar: defineVar
defineVar: defineVar
Rf_dimgets: dimnamesgets
dimgets: dimnamesgets
Rf_dimnamesgets: dimnamesgets
dimnamesgets: dimnamesgets
Rdqags: Rdqags
Rdqagi: Rdqags
Rf_duplicate: duplicate
duplicate: duplicate
DUPLICATE_ATTRIB: duplicate
Rf_dwilcox: dwilcox
dwilcox: dwilcox

E
Rf_elt: elt
elt: elt
Rf_error: error
error: error
Rf_errorcall: error
errorcall: error
Rf_eval: eval
eval: eval
R_ExecWithCleanup: R_tryCatch
R_ExpandFileName: R_ExpandFileName
exp_rand: GetRNGstate
R_ExternalPtrAddr: R_MakeExternalPtr
R_ExternalPtrAddrFn: R_MakeExternalPtr
R_ExternalPtrProtected: R_MakeExternalPtr
R_ExternalPtrTag: R_MakeExternalPtr

F
Rf_findFun: findFun
findFun: findFun
R_FindSymbol: R_registerRoutines
R_finite: ISNAN
R_FINITE: ISNAN
R_forceSymbols: R_registerRoutines
R_Free: R_Calloc
Free: R_Calloc
R_free_tmpnam: R_tmpnam

G
R_gc: R_gc
Rf_GetArrayDimnames: GetArrayDimnames
GetArrayDimnames: GetArrayDimnames
Rf_getAttrib: setAttrib
getAttrib: setAttrib
R_GetCCallable: R_RegisterCCallable
Rf_getCharCE: mkChar
getCharCE: mkChar
Rf_GetColNames: GetColNames
GetColNames: GetColNames
R_GetCurrentSrcref: R_GetCurrentSrcref
Rf_GetMatrixDimnames: GetMatrixDimnames
GetMatrixDimnames: GetMatrixDimnames
Rf_GetOption1: GetOption1
GetOption1: GetOption1
Rf_GetOptionWidth: GetOption1
GetOptionWidth: GetOption1
GetRNGstate: GetRNGstate
Rf_GetRowNames: GetColNames
GetRowNames: GetColNames
R_GetSrcFilename: R_GetCurrentSrcref
R_getVar: R_getVar
R_getVarEx: R_getVar

I
i1mach: d1mach
Riconv: Riconv
Riconv_close: Riconv
Riconv_open: Riconv
Rf_inherits: inherits
inherits: inherits
Rf_install: install
install: install
INTEGER: REAL
INTEGER_ELT: REAL
INTEGER_RO: REAL
intpr: dblepr
intpr1: dblepr
Rf_iPsort: iPsort
iPsort: iPsort
Rf_isArray: isArray
isArray: isArray
Rf_isComplex: isReal
isComplex: isReal
Rf_isDataFrame: isArray
isDataFrame: isArray
Rf_isEnvironment: isReal
isEnvironment: isReal
Rf_isExpression: isReal
isExpression: isReal
Rf_isFactor: isArray
isFactor: isArray
Rf_isFunction: isReal
isFunction: isReal
Rf_isInteger: isReal
isInteger: isReal
Rf_isLanguage: isReal
isLanguage: isReal
Rf_isList: isReal
isList: isReal
Rf_isLogical: isReal
isLogical: isReal
Rf_isMatrix: isArray
isMatrix: isArray
R_IsNA: ISNAN
ISNA: ISNAN
ISNAN: ISNAN
R_IsNaN: ISNAN
R_isnancpp: ISNAN
Rf_isNewList: isReal
isNewList: isReal
Rf_isNull: isReal
isNull: isReal
Rf_isNumber: isArray
isNumber: isArray
Rf_isNumeric: isArray
isNumeric: isArray
Rf_isObject: isArray
isObject: isArray
Rf_isOrdered: isArray
isOrdered: isArray
R_isort: R_isort
Rf_isPairList: isReal
isPairList: isReal
Rf_isPrimitive: isReal
isPrimitive: isReal
Rf_isReal: isReal
isReal: isReal
Rf_isS4: isArray
isS4: isArray
Rf_isString: isReal
isString: isReal
Rf_isSymbol: isReal
isSymbol: isReal
Rf_isTs: isArray
isTs: isArray
Rf_isUnordered: isArray
isUnordered: isArray
Rf_isVector: isReal
isVector: isReal
Rf_isVectorAtomic: isReal
isVectorAtomic: isReal
Rf_isVectorList: isReal
isVectorList: isReal

L
labelpr: dblepr
Rf_lang1: LCONS
lang1: LCONS
Rf_lang2: LCONS
lang2: LCONS
Rf_lang3: LCONS
lang3: LCONS
Rf_lang4: LCONS
lang4: LCONS
Rf_lang5: LCONS
lang5: LCONS
Rf_lang6: LCONS
lang6: LCONS
Rf_lastElt: lastElt
lastElt: lastElt
lbfgsb: lbfgsb
Rf_lcons: LCONS
lcons: LCONS
LCONS: LCONS
Rf_length: XLENGTH
LENGTH: XLENGTH
length: XLENGTH
Rf_lengthgets: xlengthgets
lengthgets: xlengthgets
Rf_list1: CONS
list1: CONS
Rf_list2: CONS
list2: CONS
Rf_list3: CONS
list3: CONS
Rf_list4: CONS
list4: CONS
Rf_list5: CONS
list5: CONS
Rf_list6: CONS
list6: CONS
LOGICAL: REAL
LOGICAL_ELT: REAL
LOGICAL_RO: REAL

M
R_MakeExternalPtr: R_MakeExternalPtr
R_MakeExternalPtrFn: R_MakeExternalPtr
R_MakeUnwindCont: R_UnwindProtect
R_MakeWeakRef: R_MakeWeakRef
R_MakeWeakRefC: R_MakeWeakRef
R_malloc_gc: R_malloc_gc
MARK_NOT_MUTABLE: MARK_NOT_MUTABLE
MAYBE_REFERENCED: MARK_NOT_MUTABLE
MAYBE_SHARED: MARK_NOT_MUTABLE
Rf_mkChar: mkChar
mkChar: mkChar
Rf_mkCharCE: mkChar
mkCharCE: mkChar
Rf_mkCharLen: mkChar
mkCharLen: mkChar
Rf_mkCharLenCE: mkChar
mkCharLenCE: mkChar
R_mkClosure: R_mkClosure
Rf_mkNamed: mkNamed
mkNamed: mkNamed
Rf_mkString: mkString
mkString: mkString

N
Rf_namesgets: dimnamesgets
namesgets: dimnamesgets
Rf_ncols: nrows
ncols: nrows
R_NewEnv: R_NewEnv
R_NewPreciousMSet: R_PreserveInMSet
nmmin: lbfgsb
norm_rand: GetRNGstate
NOT_SHARED: MARK_NOT_MUTABLE
NO_REFERENCES: MARK_NOT_MUTABLE
Rf_nrows: nrows
nrows: nrows
Rf_nthcdr: nthcdr
nthcdr: nthcdr

O
onintr: onintr
R_orderVector: R_orderVector
R_orderVector1: R_orderVector

P
R_ParentEnv: R_ParentEnv
R_ParseEvalString: R_ParseVector
R_ParseString: R_ParseVector
R_ParseVector: R_ParseVector
R_PreserveInMSet: R_PreserveInMSet
R_PreserveObject: R_PreserveObject
PRINTNAME: install
Rf_PrintValue: PrintValue
PrintValue: PrintValue
Rf_protect: PROTECT
protect: PROTECT
PROTECT: PROTECT
R_ProtectWithIndex: PROTECT_WITH_INDEX
PROTECT_WITH_INDEX: PROTECT_WITH_INDEX
PutRNGstate: GetRNGstate
R_PV: PrintValue
Rf_pwilcox: dwilcox
pwilcox: dwilcox

Q
R_qsort_I: R_qsort
R_qsort_int_I: R_qsort
R_qsort: R_qsort
R_qsort_int: R_qsort
Rf_qwilcox: dwilcox
qwilcox: dwilcox

R
RAW: REAL
RAW_ELT: REAL
RAW_RO: REAL
rchkusr: R_CheckUserInterrupt
REAL: REAL
R_Realloc: R_Calloc
Realloc: R_Calloc
R_realloc_gc: R_malloc_gc
realpr: dblepr
realpr1: dblepr
REAL_ELT: REAL
REAL_RO: REAL
Rf_reEnc: reEnc
reEnc: reEnc
R_RegisterCCallable: R_RegisterCCallable
R_RegisterCFinalizer: R_RegisterFinalizer
R_RegisterCFinalizerEx: R_RegisterFinalizer
R_RegisterFinalizer: R_RegisterFinalizer
R_RegisterFinalizerEx: R_RegisterFinalizer
R_registerRoutines: R_registerRoutines
R_ReleaseFromMSet: R_PreserveInMSet
R_ReleaseObject: R_PreserveObject
REprintf: Rprintf
R_Reprotect: PROTECT_WITH_INDEX
REPROTECT: PROTECT_WITH_INDEX
REvprintf: Rprintf
Rf_revsort: R_isort
revsort: R_isort
rexit: error
Rf_installChar: install
Rf_installTrChar: install
Rf_rmultinom: rmultinom
rmultinom: rmultinom
Rprintf: Rprintf
Rf_rPsort: iPsort
rPsort: iPsort
R_rsort: R_isort
rsort_with_index: R_isort
R_RunWeakRefFinalizer: R_MakeWeakRef
Rvprintf: Rprintf
rwarn: error
Rf_rwilcox: dwilcox
rwilcox: dwilcox

S
samin: lbfgsb
R_sample_kind: R_sample_kind
Rf_ScalarComplex: ScalarReal
ScalarComplex: ScalarReal
Rf_ScalarInteger: ScalarReal
ScalarInteger: ScalarReal
Rf_ScalarLogical: ScalarReal
ScalarLogical: ScalarReal
Rf_ScalarRaw: ScalarReal
ScalarRaw: ScalarReal
Rf_ScalarReal: ScalarReal
ScalarReal: ScalarReal
Rf_ScalarString: ScalarReal
ScalarString: ScalarReal
Rf_setAttrib: setAttrib
setAttrib: setAttrib
SETCAD4R: SETCADDDR
SETCADDDR: SETCADDDR
SETCADDR: SETCADDDR
SETCADR: SETCADDDR
SETCAR: SETCADDDR
SETCDR: SETCADDDR
R_SetExternalPtrAddr: R_MakeExternalPtr
R_SetExternalPtrProtected: R_MakeExternalPtr
R_SetExternalPtrTag: R_MakeExternalPtr
Rf_setVar: defineVar
setVar: defineVar
SET_COMPLEX_ELT: REAL
SET_INTEGER_ELT: REAL
SET_LOGICAL_ELT: REAL
SET_RAW_ELT: REAL
SET_REAL_ELT: REAL
SET_STRING_ELT: STRING_ELT
SET_TAG: SETCADDDR
SET_VECTOR_ELT: VECTOR_ELT
Rf_shallow_duplicate: duplicate
shallow_duplicate: duplicate
SHALLOW_DUPLICATE_ATTRIB: duplicate
R_ShowMessage: R_ShowMessage
Rf_str2type: str2type
str2type: str2type
STRING_ELT: STRING_ELT
STRING_PTR_RO: STRING_ELT
R_strtod: R_strtod
S_alloc: R_alloc
S_realloc: R_alloc

T
TAG: SETCADDDR
R_tmpnam: R_tmpnam
R_tmpnam2: R_tmpnam
Rf_topenv: topenv
topenv: topenv
R_ToplevelExec: R_ToplevelExec
Rf_translateChar: translateChar
translateChar: translateChar
Rf_translateCharUTF8: translateChar
translateCharUTF8: translateChar
R_tryCatch: R_tryCatch
R_tryCatchError: R_tryCatch
R_tryEval: R_ToplevelExec
R_tryEvalSilent: R_ToplevelExec
Rf_type2char: str2type
type2char: str2type
Rf_type2str: str2type
type2str: str2type
Rf_type2str_nowarn: str2type
type2str_nowarn: str2type
TYPEOF: TYPEOF

U
R_unif_index: GetRNGstate
unif_rand: GetRNGstate
UNIMPLEMENTED: UNIMPLEMENTED
Rf_unprotect: PROTECT
unprotect: PROTECT
UNPROTECT: PROTECT
Rf_unprotect_ptr: UNPROTECT_PTR
unprotect_ptr: UNPROTECT_PTR
UNPROTECT_PTR: UNPROTECT_PTR
R_UnwindProtect: R_UnwindProtect
R_useDynamicSymbols: R_registerRoutines

V
VECTOR_ELT: VECTOR_ELT
VECTOR_PTR_RO: VECTOR_ELT
R_Version: R_Version
vmaxget: R_alloc
vmaxset: R_alloc
vmmin: lbfgsb

W
Rf_warning: error
warning: error
Rf_warningcall: error
warningcall: error
Rf_warningcall_immediate: error
warningcall_immediate: error
R_WeakRefKey: R_MakeWeakRef
R_WeakRefValue: R_MakeWeakRef
wilcox_free: dwilcox
R_withCallingErrorHandler: R_tryCatch

X
Rf_xlength: XLENGTH
XLENGTH: XLENGTH
xlength: XLENGTH
Rf_xlengthgets: xlengthgets
xlengthgets: xlengthgets

Jump to:   A   B   C   D   E   F   G   I   L   M   N   O   P   Q   R   S   T   U   V   W   X  

Previous: , Up: Indices   [Index]

5.3 Experimental API


Next: , Up: Experimental API   [Index]

5.3.1 Functions

Jump to:   A   B   C   D   E   F   G   H   I   L   M   N   P   R   S   U   V  
Index Entry  Section

A
R_ActiveBindingFunction: R_MakeActiveBinding
Rf_AdobeSymbol2utf8: Rf_ucstoutf8
AdobeSymbol2utf8: Rf_ucstoutf8
Rf_allocS4Object: allocS4Object
allocS4Object: allocS4Object
ALTREP: ALTREP
ALTREP_CLASS: ALTREP
R_altrep_data1: R_new_altrep
R_altrep_data2: R_new_altrep
R_altrep_inherits: ALTREP
Rf_any_duplicated: duplicated
any_duplicated: duplicated
Rf_any_duplicated3: duplicated
any_duplicated3: duplicated
Rf_asS4: asS4
asS4: asS4

B
R_BindingIsActive: R_MakeActiveBinding
R_BindingIsLocked: R_LockBinding

C
Rf_charIsASCII: charIsUTF8
charIsASCII: charIsUTF8
Rf_charIsLatin1: charIsUTF8
charIsLatin1: charIsUTF8
Rf_charIsUTF8: charIsUTF8
charIsUTF8: charIsUTF8
R_check_class_etc: R_check_class_etc
R_chk_calloc: R_chk_calloc
R_chk_free: R_chk_calloc
R_chk_realloc: R_chk_calloc
COMPLEX_GET_REGION: REAL_GET_REGION
COMPLEX_OR_NULL: DATAPTR_OR_NULL
R_compute_identical: R_compute_identical
Rf_copyListMatrix: copyListMatrix
copyListMatrix: copyListMatrix

D
DATAPTR_OR_NULL: DATAPTR_OR_NULL
R_do_MAKE_CLASS: R_getClassDef
R_do_new_object: R_do_new_object
R_do_slot: R_do_slot
R_do_slot_assign: R_do_slot
Rf_duplicated: duplicated
duplicated: duplicated

E
R_EnvironmentIsLocked: R_LockEnvironment
R_existsVarInFrame: R_existsVarInFrame

F
R_FindNamespace: R_FindNamespace
R_forceAndCall: R_forceAndCall

G
R_getClassDef: R_getClassDef
R_GetX11Image: R_GetX11Image

H
R_has_slot: R_do_slot

I
R_InitFileInPStream: R_Serialize
R_InitFileOutPStream: R_Serialize
R_InitInPStream: R_Serialize
R_InitOutPStream: R_Serialize
INTEGER_GET_REGION: REAL_GET_REGION
INTEGER_IS_SORTED: REAL_IS_SORTED
INTEGER_NO_NA: REAL_NO_NA
INTEGER_OR_NULL: DATAPTR_OR_NULL
Rf_isBlankString: StringBlank
isBlankString: StringBlank
R_IsNamespaceEnv: R_FindNamespace
R_IsPackageEnv: R_PackageEnvName
Rf_isUnsorted: isUnsorted
isUnsorted: isUnsorted
Rf_isVectorizable: isVectorizable
isVectorizable: isVectorizable
IS_LONG_VEC: IS_LONG_VEC
IS_SCALAR: IS_SCALAR

L
Rf_listAppend: listAppend
listAppend: listAppend
R_LockBinding: R_LockBinding
R_LockEnvironment: R_LockEnvironment
LOGICAL_GET_REGION: REAL_GET_REGION
LOGICAL_NO_NA: REAL_NO_NA
LOGICAL_OR_NULL: DATAPTR_OR_NULL
R_lsInternal3: R_lsInternal3

M
R_MakeActiveBinding: R_MakeActiveBinding
R_make_altcomplex_class: R_make_altcomplex_class
R_make_altinteger_class: R_make_altinteger_class
R_make_altlist_class: R_make_altlist_class
R_make_altlogical_class: R_make_altlogical_class
R_make_altraw_class: R_make_altraw_class
R_make_altreal_class: R_make_altreal_class
R_make_altstring_class: R_make_altstring_class
Rf_match: psmatch
match: psmatch

N
R_NamespaceEnvSpec: R_FindNamespace
R_new_altrep: R_new_altrep
Rf_nlevels: nlevels
nlevels: nlevels

P
R_PackageEnvName: R_PackageEnvName
Rf_PairToVectorList: PairToVectorList
PairToVectorList: PairToVectorList
Rf_pmatch: psmatch
pmatch: psmatch
Rf_psmatch: psmatch
psmatch: psmatch

R
RAW_GET_REGION: REAL_GET_REGION
RAW_OR_NULL: DATAPTR_OR_NULL
REAL_GET_REGION: REAL_GET_REGION
REAL_IS_SORTED: REAL_IS_SORTED
REAL_NO_NA: REAL_NO_NA
REAL_OR_NULL: DATAPTR_OR_NULL
R_removeVarFromFrame: R_existsVarInFrame
Rf_ucstoutf8: Rf_ucstoutf8

S
R_Serialize: R_Serialize
R_set_altcomplex_Elt_method: R_make_altcomplex_class
R_set_altcomplex_Get_region_method: R_make_altcomplex_class
R_set_altinteger_Elt_method: R_make_altinteger_class
R_set_altinteger_Get_region_method: R_make_altinteger_class
R_set_altinteger_Is_sorted_method: R_make_altinteger_class
R_set_altinteger_Max_method: R_make_altinteger_class
R_set_altinteger_Min_method: R_make_altinteger_class
R_set_altinteger_No_NA_method: R_make_altinteger_class
R_set_altinteger_Sum_method: R_make_altinteger_class
R_set_altlist_Elt_method: R_make_altlist_class
R_set_altlist_Set_elt_method: R_make_altlist_class
R_set_altlogical_Elt_method: R_make_altlogical_class
R_set_altlogical_Get_region_method: R_make_altlogical_class
R_set_altlogical_Is_sorted_method: R_make_altlogical_class
R_set_altlogical_No_NA_method: R_make_altlogical_class
R_set_altlogical_Sum_method: R_make_altlogical_class
R_set_altraw_Elt_method: R_make_altraw_class
R_set_altraw_Get_region_method: R_make_altraw_class
R_set_altreal_Elt_method: R_make_altreal_class
R_set_altreal_Get_region_method: R_make_altreal_class
R_set_altreal_Is_sorted_method: R_make_altreal_class
R_set_altreal_Max_method: R_make_altreal_class
R_set_altreal_Min_method: R_make_altreal_class
R_set_altreal_No_NA_method: R_make_altreal_class
R_set_altreal_Sum_method: R_make_altreal_class
R_set_altrep_Coerce_method: R_set_altrep_..._method
R_set_altrep_data1: R_new_altrep
R_set_altrep_data2: R_new_altrep
R_set_altrep_DuplicateEX_method: R_set_altrep_..._method
R_set_altrep_Duplicate_method: R_set_altrep_..._method
R_set_altrep_Inspect_method: R_set_altrep_..._method
R_set_altrep_Length_method: R_set_altrep_..._method
R_set_altrep_Serialized_state_method: R_set_altrep_..._method
R_set_altrep_UnserializeEX_method: R_set_altrep_..._method
R_set_altrep_Unserialize_method: R_set_altrep_..._method
R_set_altstring_Elt_method: R_make_altstring_class
R_set_altstring_Is_sorted_method: R_make_altstring_class
R_set_altstring_No_NA_method: R_make_altstring_class
R_set_altstring_Set_elt_method: R_make_altstring_class
R_set_altvec_Dataptr_method: R_set_altvec_..._method
R_set_altvec_Dataptr_or_null_method: R_set_altvec_..._method
R_set_altvec_Extract_subset_method: R_set_altvec_..._method
Rf_StringBlank: StringBlank
StringBlank: StringBlank
Rf_StringFalse: StringBlank
StringFalse: StringBlank
Rf_StringTrue: StringBlank
StringTrue: StringBlank
STRING_IS_SORTED: REAL_IS_SORTED
STRING_NO_NA: REAL_NO_NA

U
R_unLockBinding: R_LockBinding
R_Unserialize: R_Serialize
Rf_utf8toAdobeSymbol: Rf_ucstoutf8
utf8toAdobeSymbol: Rf_ucstoutf8
Rf_utf8ToLatin1AdobeSymbol2utf8: Rf_ucstoutf8
utf8ToLatin1AdobeSymbol2utf8: Rf_ucstoutf8
Rf_utf8Toutf8NoPUA: Rf_ucstoutf8
utf8Toutf8NoPUA: Rf_ucstoutf8

V
Rf_VectorToPairList: PairToVectorList
VectorToPairList: PairToVectorList

Jump to:   A   B   C   D   E   F   G   H   I   L   M   N   P   R   S   U   V  

Previous: , Up: Introduction   [Index]

6 Self-test results

Number of matching entries of class api: 334
Extraneous entries of class api:
[1] "rwilcox"
Undocumented entries of class api:
 [1] "bessel_i"      "bessel_j"      "bessel_k"      "bessel_y"     
 [5] "beta"          "choose"        "cospi"         "digamma"      
 [9] "dpsifn"        "expm1"         "findInterval"  "findInterval2"
[13] "fmax2"         "fmin2"         "fprec"         "fround"       
[17] "fsign"         "ftrunc"        "gammafn"       "imax2"        
[21] "imin2"         "interv"        "lbeta"         "lchoose"      
[25] "lgamma1p"      "lgammafn"      "log1mexp"      "log1p"        
[29] "log1pexp"      "log1pmx"       "logspace_add"  "logspace_sub" 
[33] "logspace_sum"  "pentagamma"    "pow1p"         "psigamma"     
[37] "qsort3"        "qsort4"        "R_max_col"     "R_pow"        
[41] "R_pow_di"      "Rtanpi"        "sign"          "signrank_free"
[45] "sinpi"         "tanpi"         "tetragamma"    "trigamma"     
Number of matching entries of class eapi: 137
Undocumented entries of class eapi:
  [1] "col2name"                     "CreateAtVector"              
  [3] "curDevice"                    "desc2GEDesc"                 
  [5] "doesIdle"                     "doIdle"                      
  [7] "doKeybd"                      "doMouseEvent"                
  [9] "GAxisPars"                    "GE_LENDget"                  
 [11] "GE_LENDpar"                   "GE_LJOINget"                 
 [13] "GE_LJOINpar"                  "GE_LTYget"                   
 [15] "GE_LTYpar"                    "GEaddDevice"                 
 [17] "GEaddDevice2"                 "GEaddDevice2f"               
 [19] "GECap"                        "GEcheckState"                
 [21] "GECircle"                     "GEcontourLines"              
 [23] "GEcopyDisplayList"            "GEcreateDevDesc"             
 [25] "GEcreateSnapshot"             "GEcurrentDevice"             
 [27] "GEdestroyDevDesc"             "GEdeviceDirty"               
 [29] "GEdeviceNumber"               "GEdirtyDevice"               
 [31] "GEExpressionHeight"           "GEExpressionMetric"          
 [33] "GEExpressionWidth"            "GEFill"                      
 [35] "GEFillStroke"                 "GEfromDeviceHeight"          
 [37] "GEfromDeviceWidth"            "GEfromDeviceX"               
 [39] "GEfromDeviceY"                "GEgetDevice"                 
 [41] "GEGlyph"                      "GEhandleEvent"               
 [43] "GEinitDisplayList"            "GEkillDevice"                
 [45] "GELine"                       "GEMathText"                  
 [47] "GEMetricInfo"                 "GEMode"                      
 [49] "GENewPage"                    "GEnullDevice"                
 [51] "GEonExit"                     "GEPath"                      
 [53] "GEplayDisplayList"            "GEplaySnapshot"              
 [55] "GEPolygon"                    "GEPolyline"                  
 [57] "GEPretty"                     "GERaster"                    
 [59] "GErecordGraphicOperation"     "GErecording"                 
 [61] "GERect"                       "GEregisterSystem"            
 [63] "GEregisterWithDevice"         "GESetClip"                   
 [65] "GEStrHeight"                  "GEstring_to_pch"             
 [67] "GEStrMetric"                  "GEStroke"                    
 [69] "GEStrWidth"                   "GESymbol"                    
 [71] "GEsystemState"                "GEText"                      
 [73] "GEtoDeviceHeight"             "GEtoDeviceWidth"             
 [75] "GEtoDeviceX"                  "GEtoDeviceY"                 
 [77] "GEunregisterSystem"           "GEXspline"                   
 [79] "killDevice"                   "ndevNumber"                  
 [81] "NewFrameConfirm"              "nextDevice"                  
 [83] "NoDevices"                    "NumDevices"                  
 [85] "prevDevice"                   "R_CheckDeviceAvailable"      
 [87] "R_CheckDeviceAvailableBool"   "R_GE_checkVersionOrDie"      
 [89] "R_GE_clipPathFillRule"        "R_GE_getVersion"             
 [91] "R_GE_glyphColour"             "R_GE_glyphFont"              
 [93] "R_GE_glyphFontFamily"         "R_GE_glyphFontFile"          
 [95] "R_GE_glyphFontIndex"          "R_GE_glyphFontPSname"        
 [97] "R_GE_glyphFontStyle"          "R_GE_glyphFontWeight"        
 [99] "R_GE_glyphID"                 "R_GE_glyphInfoFonts"         
[101] "R_GE_glyphInfoGlyphs"         "R_GE_glyphRotation"          
[103] "R_GE_glyphSize"               "R_GE_glyphX"                 
[105] "R_GE_glyphY"                  "R_GE_hasGlyphRotation"       
[107] "R_GE_isPattern"               "R_GE_linearGradientColour"   
[109] "R_GE_linearGradientExtend"    "R_GE_linearGradientNumStops" 
[111] "R_GE_linearGradientStop"      "R_GE_linearGradientX1"       
[113] "R_GE_linearGradientX2"        "R_GE_linearGradientY1"       
[115] "R_GE_linearGradientY2"        "R_GE_maskType"               
[117] "R_GE_patternType"             "R_GE_radialGradientColour"   
[119] "R_GE_radialGradientCX1"       "R_GE_radialGradientCX2"      
[121] "R_GE_radialGradientCY1"       "R_GE_radialGradientCY2"      
[123] "R_GE_radialGradientExtend"    "R_GE_radialGradientNumStops" 
[125] "R_GE_radialGradientR1"        "R_GE_radialGradientR2"       
[127] "R_GE_radialGradientStop"      "R_GE_rasterInterpolate"      
[129] "R_GE_rasterResizeForRotation" "R_GE_rasterRotate"           
[131] "R_GE_rasterRotatedOffset"     "R_GE_rasterRotatedSize"      
[133] "R_GE_rasterScale"             "R_GE_str2col"                
[135] "R_GE_tilingPatternExtend"     "R_GE_tilingPatternFunction"  
[137] "R_GE_tilingPatternHeight"     "R_GE_tilingPatternWidth"     
[139] "R_GE_tilingPatternX"          "R_GE_tilingPatternY"         
[141] "R_GE_VStrHeight"              "R_GE_VStrWidth"              
[143] "R_GE_VText"                   "RGBpar"                      
[145] "RGBpar3"                      "selectDevice"                
R Under development (unstable) (2024-10-10 r87218)

Footnotes

(1)

https://stat.ethz.ch/pipermail/r-help/2024-July/479719.html

(2)

https://bugs.r-project.org/show_bug.cgi?id=18748

(3)

https://bugs.r-project.org/show_bug.cgi?id=17599

(4)

https://bugs.r-project.org/show_bug.cgi?id=18805

(5)

https://bugs.r-project.org/show_bug.cgi?id=18794

(6)

https://bugs.r-project.org/show_bug.cgi?id=18775

(7)

https://bugs.r-project.org/show_bug.cgi?id=18778