Skip to main content Link Search Menu Expand Document (external link)

Procedure 12: Labelling a Matrix.

As seen in procedure 24 it is helpful for reference to label a Vector. It is possible also to label the rows and the columns of a matrix in a similar fashion using the rownames() and colnames() function.

To set column names assign a Vector to the colnames() function, where the colnames() function accepts the matrix as its argument:

colnames(OverspillMatrix) <- c("Example1","Example2","Example3","Example4")

img.png

Run the line of script to console:

img_1.png

The rownames() function has a similar signature and takes a Vector of row names:

rownames(OverspillMatrix) <- c("Row1","Row2","Row3")

img_2.png

Run the line of script to console:

img_3.png

The matrix is now labelled in both directions and can be inspected by typing:

OverspillMatrix

img_4.png

Run the line of script to console:

img_5.png


Jube™. © Jube Holdings Limited 2022 to present.