# VECTOR - PART 1 x <- c(2,3,5,1,4,4) # creates vector of length 6 # with elements 2,3,5,1,4,4 x # prints out x length(x) # gives cardinal number (length) # of vector x y <- c(8,2,3,3,5,1,7,7,7) # creates vector y of length 9 z <- c(x,y) # z is x concatenated with y x;y;z # print out vectors x, y, and z w <- c(1,4,7,6,2,5) # creates another vector # of length 6 print(x+w) # adds corresponding elements # of x and w --note that # vectors must have same length x^2 # squares every element of x x + y # adds x and y--where y has longer # length x values start from # 1st element value again 3 * x # each x element is multiplied by 3 c(1:10) # vector from 1 to 10 created seq(1,10,by=2) # vector from 1 to 10 by 2's created c(1:4,8,22) # vector of 1 to 4 sequence, then 8,22 x[-c(2,3)] # print x vector without 2nd and # 3rd elements