########################################################## ## Jake Russell ## 1602835 ########################################################## # 1. v1<-(1:12)#generate v1 with values going from 1 to 12 #2. v1<-c(v1,13:16)#concatonate v1 with values going from 13 to 16 #3. v2<-c(v1[1], v1[7], v1[12], v1[16])#creates v2 concatonating the contents of v1's 1st, 7th, 12th, and 16th elements #4. v1+v2#adds v1 to v2 #as v2 is shorter than v1 the operation recycle v2 until the end of v1 #5. v3<-v1[v1%%2==0]#calculate modulus of 2 for each element and if it's equal to 0 place into v3 #6. m1<-matrix(v1, nrow=4)#create a matrix for v1 with 4 rows #7. m2<-matrix(v2, ncol = 3)#create a matrix for v2 with 3 columns #8. m3<-matrix(c(m1, m2), ncol = 7 )#create a matrix from m1 and m2 containing all of the columns m3#display m3 #9. colnames(m3)<-c("a","b","c","d","e","f","g")#names the colomns respectively #10. m3<-m3[-3,]#removes row 3 from m3 #11. apply(m3, 2, mean)#applies the mean function to every column #12. barplot(m3[1,])#create a barplot of row 1 from m3