Vector in R
A
vector can be a vector of characters, logical, integers or numeric. Creating
object for Vector using vector() or c().
#
Empty
Command::
v<-vector()
Print::
print(v)
Output :: logical(0)
#
Predefined Length
v <- vector(length = 10)
print(v)
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
FALSE FALSE FALSE
#
x <- c(1, 2, 3)
print(x)
[1]
1 2 3
#
m
<- c(1L, 2L, 3L)
print(m)
[1]
1 2 3
#
y
<- c(TRUE, TRUE, FALSE, FALSE)
print(y)
[1] TRUE
TRUE FALSE FALSE
#
z <- c("Andrew",
"Zach", "Mike")
print(z)
[1]
"Andrew" "Zach"
"Mike"
Vector in R
Reviewed by Rupesh
on
23:51
Rating:
No comments: