as.numeric
, as.character
, as.logical
, as.integer
- “coerces”/changes a vector into that data type - MAY RESULT in NA
is.numeric
, is.character
, is.logical
, is.integer
gives a single TRUE
or FALSE
if that vector is that class
is.logical(c(TRUE, FALSE))
## [1] TRUE
is.numeric(c(TRUE, FALSE))
## [1] FALSE
as.numeric(c(TRUE, FALSE))
## [1] 1 0
as.numeric(c("5", "0", "$0 "))
## Warning: NAs introduced by coercion
## [1] 5 0 NA
as.character(c(TRUE, FALSE))
## [1] "TRUE" "FALSE"
as.integer(c(TRUE, FALSE))
## [1] 1 0
as.logical(c(5, 0))
## [1] TRUE FALSE