x<-c(7,8,0,6,4,3,9,10,2,1,8)
length(x)#the length of a vector
## [1] 11
x[5]#the fifth element of a vector
## [1] 4
x[-3]#all elements except the third element
## [1] 7 8 6 4 3 9 10 2 1 8
x[1:3]#the elements from 1 to 3
## [1] 7 8 0
x[c(2,4,6)]#the elements 2,4,6
## [1] 8 6 3
x[1]=12;x#Replace first element of a vector
## [1] 12 8 0 6 4 3 9 10 2 1 8
x[1:3]<-7;x#Replace the elements from 1 to 3 with 7
## [1] 7 7 7 6 4 3 9 10 2 1 8
x[c(1,4,9)]<-c(2,5,7);x#Replace the elements 1,4,9 with 2,5,7
## [1] 2 7 7 5 4 3 9 10 7 1 8
x[x>5]<-3;x #Replace the values greater than 5 with 3
## [1] 2 3 3 5 4 3 3 3 3 1 3