Matrices in R
Matrices
are a special vector in R which holds row and column attributes. It can be
created using a vector input to the matrix function.
#
Empty
Command::
m <- matrix(1:6, nrow=2, ncol =3)
Print::
print(m)
Output::
[,1]
[,2] [,3]
[1,] 1
3 5
[2,] 2
4 6
We
can also bind rows /column wise using the command cbind() and rbind()
x <- 5:7
y <- 6:8
rbind(x,y)
[,1] [,2] [,3]
x 5
6 7
y 6
7 8
cbind(x,y)
x y
[1,] 5 6
[2,] 6 7
[3,] 7 8
Matrices in R
Reviewed by Rupesh
on
00:04
Rating:
No comments: