coerceVector | R Documentation |
Coerces a Vector
coerceVector(v, type)
v |
(SEXP) An R object. |
type |
(SEXPTYPE) An macro constant of length one. |
coerceVector()
returns an SEXP object of type SEXPTYPE type
.
#include <Rinternals.h> SEXP Rf_coerceVector(SEXP, SEXPTYPE) #define coerceVector Rf_coerceVector
Related macros:
#include <Rdefines.h> #define AS_LOGICAL(x) Rf_coerceVector(x,LGLSXP) #define AS_INTEGER(x) Rf_coerceVector(x,INTSXP) #define AS_NUMERIC(x) Rf_coerceVector(x,REALSXP) #define AS_CHARACTER(x) Rf_coerceVector(x,STRSXP) #define AS_COMPLEX(x) Rf_coerceVector(x,CPLXSXP) #define AS_VECTOR(x) Rf_coerceVector(x,VECSXP) #define AS_LIST(x) Rf_coerceVector(x,VECSXP) #define AS_RAW(x) Rf_coerceVector(x,RAWSXP)
library(base) x <- 1:5 y_integer <- as.integer(x) y_logical <- as.logical(x) y_numeric <- as.numeric(x) y_character <- as.character(x)
Declaration: src/include/Rinternals.h and src/include/Rdefines.h
Implementation: src/main/coerce.c
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.