How to assign names to Matrix in R

r

#1

I have created a matrix I want to assign names to matrix
m<-matrix(1:4,nrow=2,ncol=2)
and I want it like
c d
a 1 3
b 2 4


#2

You can assign the names via dimname argument to matrix(). See ?matrix for more information.