coerceVector.Rd
Coerces a Vector
coerceVector(v, type)
Declaration: src/include/Rinternals.h and src/include/Rdefines.h
Implementation: src/main/coerce.c
#include <Rinternals.h>
(SEXP, SEXPTYPE)
SEXP Rf_coerceVector#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)