A matrix stores one data type in two dimensions. Column functions summarize values by column.

Program

Play the script to build a two-row matrix and choose the last column total.

matrices.R
grid <- matrix(1:6, nrow = 2)
column_totals <- colSums(grid)
last_total <- column_totals[3]
cat(last_total, "\n", sep = "")
matrix `matrix(1:6, nrow = 2)` creates a rectangular numeric structure.
colSums `colSums` adds values down each column.
dimension Matrices keep row and column shape in `dim`.