Created
April 16, 2012 18:04
-
-
Save geofferyzh/2400391 to your computer and use it in GitHub Desktop.
RinAction - R Data Structure - Vectors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-----------------------------------------------------------------------------# | |
# R in Action - R Data Structures # | |
# - Working with Vectors, Matrices, Arrays,Dataframes & Lists # | |
#-----------------------------------------------------------------------------# | |
################################# | |
# Vectors # | |
################################# | |
# creating vectors | |
a <- c(1, 2, 5, 3, 6, -2, 4) | |
b <- c("one", "two", "three") | |
c <- c(TRUE, TRUE, TRUE, FALSE, TRUE, FALSE) | |
# Vectors with repeating values | |
s <- rep(C("a"),5) | |
s <- rep(c("a","b"),5) | |
s <- rep(c("a","b"),c(5,2)) | |
s | |
# Using vector subscripts | |
a <- c(1, 2, 5, 3, 6, -2, 4) | |
a[3] | |
a[c(1, 3, 5)] | |
a[2:6] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment