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