Example: 1, 2, 3, ...
1, 2, 3, ...
x <- c(1, 2, 3) x
## [1] 1 2 3
is.numeric(x)
## [1] TRUE
as.character(x)
## [1] "1" "2" "3"
Example: "a", "b", "c", ...
"a", "b", "c", ...
x <- c("1", "2", "3") x
is.character(x)
as.numeric(x)
Example: mix of both
c(1, "b", 3)
## [1] "1" "b" "3"
Example: TRUE of FALSE
TRUE
FALSE
x <- 1:10 < 5 x
## [1] TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
!x
## [1] FALSE FALSE FALSE FALSE TRUE TRUE TRUE TRUE TRUE TRUE
which(x) # Returns index for the 'TRUE' values in logical vector
## [1] 1 2 3 4