allocVector | R Documentation |
Allocates a Vector
allocVector(type, length)
type |
(SEXPTYPE) An macro constant of length one. |
length |
(R_xlen_t) An non-negative integer. |
allocVector()
returns an SEXP object of type SEXPTYPE type
.
#include <Rinternals.h> SEXP Rf_allocVector(SEXPTYPE, R_xlen_t) #define allocVector Rf_allocVector
Related macros:
#include <Rdefines.h> #define NEW_LOGICAL(n) Rf_allocVector(LGLSXP,n) #define NEW_INTEGER(n) Rf_allocVector(INTSXP,n) #define NEW_NUMERIC(n) Rf_allocVector(REALSXP,n) #define NEW_CHARACTER(n) Rf_allocVector(STRSXP,n) #define NEW_COMPLEX(n) Rf_allocVector(CPLXSXP,n) #define NEW_LIST(n) Rf_allocVector(VECSXP,n) #define NEW_STRING(n) NEW_CHARACTER(n) #define NEW_RAW(n) Rf_allocVector(RAWSXP,n)
library(base) x_logical <- logical(length = n) x_integer <- integer(length = n) x_numeric <- numeric(length = n) x_character <- character(length = n) x_complex <- complex(length.out = n) x_list <- vector(mode = "list", length = n) x_raw <- raw(length = n)
Declaration: src/include/Rinternals.h and src/include/Rdefines.h
Implementation: allocVector(SEXPTYPE type, R_xlen_t length)
is a simple inline wrapper functions that calls allocVector3(type, length, NULL)
, cf. src/include/Rinlinedfuns.h
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.