Retrieve or set the dimension of an object.

1 2 |

`x` |
an |

`value` |
For the default method, either |

The functions `dim`

and `dim<-`

are internal generic
primitive functions.

`dim`

has a method for `data.frame`

s, which returns
the lengths of the `row.names`

attribute of `x`

and
of `x`

(as the numbers of rows and columns respectively).

For an array (and hence in particular, for a matrix) `dim`

retrieves
the `dim`

attribute of the object. It is `NULL`

or a vector
of mode `integer`

.

The replacement method changes the `"dim"`

attribute (provided the
new value is compatible) and removes any `"dimnames"`

*and*
`"names"`

attributes.

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

`ncol`

, `nrow`

and `dimnames`

.

1 2 3 4 5 6 |

What can we improve?

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.

Close