[ top | up ]

The Number of Columns of a Matrix

Syntax

ncol(x)
NCOL(x)

Arguments

x array

Description

ncol returns the number of columns present in its argument. NCOL does the same, but dealing a vector as 1-column matrix.

See Also

nrow and NROW.

Examples

ncol(matrix(1:12, 3, 4)) # 4 ncol(array(1:24, dim= 2:4)) # 3, the second dimension NCOL(1:12) # 1