# Adding and dropping rows and columns

# Create matrix m

m<-matrix(c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16), nrow=4, byrow=T)

# Display m

m

# Add extra row using rbind()

m<-rbind(m,c(17,18,19,20))

# Display m

m

# Drop column 3 by reassigning m

m<-m[,-3]   # Remember that you need the comma!

# Display m

m

# Insert column of zeros using rbind()

m<-rbind(m[1,],c(0),m[2:5,]) # Can use c(0) as the zeros recycle

# Display m

m