EVOLUTION-MANAGER
Edit File: nrow.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: The Number of Rows/Columns of an Array</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for nrow {base}"><tr><td>nrow {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>The Number of Rows/Columns of an Array</h2> <h3>Description</h3> <p><code>nrow</code> and <code>ncol</code> return the number of rows or columns present in <code>x</code>. <code>NCOL</code> and <code>NROW</code> do the same treating a vector as 1-column matrix, even a 0-length vector, compatibly with <code><a href="matrix.html">as.matrix</a>()</code> or <code><a href="cbind.html">cbind</a>()</code>, see the example. </p> <h3>Usage</h3> <pre> nrow(x) ncol(x) NCOL(x) NROW(x) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>a vector, array, data frame, or <code><a href="NULL.html">NULL</a></code>.</p> </td></tr> </table> <h3>Value</h3> <p>an <code><a href="integer.html">integer</a></code> of length 1 or <code><a href="NULL.html">NULL</a></code>, the latter only for <code>ncol</code> and <code>nrow</code>.</p> <h3>References</h3> <p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) <em>The New S Language</em>. Wadsworth & Brooks/Cole (<code>ncol</code> and <code>nrow</code>.) </p> <h3>See Also</h3> <p><code><a href="dim.html">dim</a></code> which returns <em>all</em> dimensions; <code><a href="array.html">array</a></code>, <code><a href="matrix.html">matrix</a></code>. </p> <h3>Examples</h3> <pre> ma <- matrix(1:12, 3, 4) nrow(ma) # 3 ncol(ma) # 4 ncol(array(1:24, dim = 2:4)) # 3, the second dimension NCOL(1:12) # 1 NROW(1:12) # 12 ## as.matrix() produces 1-column matrices from 0-length vectors, ## and so does cbind() : dim(as.matrix(numeric())) # 0 1 dim( cbind(numeric())) # ditto ## consequently, NCOL(.) gives 1, too : NCOL(numeric()) # 1 and hence NCOL(NULL) # 1 </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>