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: 5

No comments:

All Rights Reserved by Technology from Developers Eye © 2014 - 2015
Powered By Blogger, Designed by Aadics
Disclaimers:: The information provided within this blogsite is for general informational purposes only. While we try to keep the information up-to-date and correct, there are no representations or warranties, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the information, products, services, or related graphics contained in this blogsite for any purpose.The author does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause.

Contact Form

Name

Email *

Message *

Powered by Blogger.