Movatterモバイル変換


[0]ホーム

URL:


rdrr.io

nrow: The Number of Rows/Columns of an Array

nrowR Documentation

The Number of Rows/Columns of an Array

Description

nrow andncol return the number of rows or columnspresent inx.NCOL andNROW do the same treating a vector as1-column matrix, even a 0-length vector, compatibly withas.matrix() orcbind(), see the example.

Usage

nrow(x)ncol(x)NCOL(x)NROW(x)

Arguments

x

a vector, array, data frame, orNULL.

Value

aninteger of length 1 orNULL, thelatter only forncol andnrow.

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)The New S Language.Wadsworth & Brooks/Cole (ncol andnrow.)

See Also

dim which returnsall dimensions, andlength which gives a number (a ‘count’) also in cases wheredim() isNULL, and hencenrow() andncol()returnNULL;array,matrix.

Examples

ma <- matrix(1:12, 3, 4)nrow(ma)   # 3ncol(ma)   # 4ncol(array(1:24, dim = 2:4)) # 3, the second dimensionNCOL(1:12) # 1NROW(1:12) # 12, the length() of the vector## as.matrix() produces 1-column matrices from 0-length vectors,## and so does cbind() :dim(as.matrix(numeric())) # 0 1dim(    cbind(numeric())) # ditto## consequently, NCOL(.) gives 1, too :NCOL(numeric()) # 1 and henceNCOL(NULL)      # 1

What can we improve?

R Package Documentation

Browse R Packages

We want your feedback!

Note that we can't provide technical support on individual packages. You should contact the package authors for that.

 
Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, readEmbedding Snippets.

Close

[8]ページ先頭

©2009-2026 Movatter.jp