# Kai Strand-Regan
# 1801495
# Computing

#Creating v1 
v1<-c(1,2,3,4,5,6,7,8,9,10,11,12) 
v1

#adding 13-16 to the end of v1
v1<-c(v1,13,14,15,16)
v1

#creating a new vector to hold the values from 1-7 and 12-16 from v1

v2<- c(v1[1:7],v1[12:16]) 
v2  

#originally this was used but the resault was not as intended
#v2<-seq(from=1, to=7 && from=12, to=16)


#this creates a warning message as it has to loop around to the begining of the shorter vecter so ot is able to add all the values from v1
v1+v2

#odd = false even = true
v3=v1%%2==0
v3

#this allows the matrix to work otherwise it only gets 12 values from the first v1
v1<-c(v1,13,14,15,16)
v1[16]

#the matrix contains all the values from v1 with 4 rows so the columns are also 4 as 4x4=16
m1<-matrix(v1, nrow=4)
m1
# giving v2 3 columns, again as the number reaches 16 it still has 4 rows
m2<-matrix(v2, ncol=3)
m2

#creating a new matrix with the values from m1 and m2, it has 7 columns as they are going to be named from a-f
m3<-matrix(m1, m2, ncol=7, nrow=4)
m3

#naming the columns a-f, row names might show here 
colnames(m3)<-c("a","b","c","d","e","f","g")
m3

#This was practise "m3<-matrix(c(ncol =v1, nrow=v2,1:7))"

#removing row 3, if it was to remove a column the comma would simply go infrom of the 3
m3<-m3[-3,]
m3

#calculating mean of each column, 
mean(m3[,1])

mean(m3[,2])

mean(m3[,3])

mean(m3[,4])

mean(m3[,5])

mean(m3[,6])

mean(m3[,7])

#naming rows to identify them on barplot, this did not help so it has been comented out
#rownames(m3)<-c("one","two","three","four")
#a few attemts were made but none worked. 
table(m3["one"])
barplot(xtabs(m3$one))

#unfortunately this section was not completed
