| as.rectangular | R Documentation |
Functions that allow you to access all rectangular data objects in the same way. Rectangular data objects include matrices, data frames and vectors.
as.rectangular(x)
as.char.rect(x)
is.rectangular(x)
subscript2d(x,i,j)
subscript2d(x,i,j) <- value
numRows(x)
numRows(x) <- value
numCols(x)
numCols(x) <- value
rowIds(x)
rowIds(x) <- value
colIds(x)
colIds(x) <- value
x |
the object to be converted to rectangular data ( |
i |
the first (row) subscript. |
j |
the second (column) subscript. |
value |
the object to be assign to |
subscript2d, numRows, numCols, rowIds,
colIds can also be used on the left side of assignments. The value can be a character vector, or anything that
can be coerced to a character vector.
subscript2d is for subscripting. When subscript2d is used in an assignment, it does not allow subscript replacement
outside the bounds of x. Instead, set numRows or
numCols first.
When numRows or numCols is used in
an assignment, the row and column IDs are maintained
to have the correct length. Usually, this is done by setting numRows on the ID vector,
but for some objects (for example, data frames)
this might not be appropriate, and they have their own methods.
Functions colnames<- and rownames<- simply call
colIds<- and rowIds<-, respectively.
as.rectangular converts any object to a rectangular
data object (usually a data frame), if possible.
is.rectangular tests whether an object is rectangular.
numRows and numCols count the number of rows and columns.
rowIds and colIds (and rownames and
colnames) return the row and column names or other
identifiers attached to rows and columns.
colnames and rownames return the same values as
colIds and rowIds, respectively, if do.NULL=T.
Instead of using names to replace row names from a matrix,
use rowIds or dimnames.
The functions colnames, rownames,
colnames<-, rownames<- emulate R
functions of the same names.
as.rectangular |
returns |
as.char.rect |
takes a rectangular object and returns a rectangular object (vector or matrix) consisting of character strings, suitable for printing (but not formatted to fixed width). |
is.rectangular |
returns |
subscript2d(x,i,j) |
is like |
numRows and numCols |
return integers, like |
rowIds and colIds |
return the IDs of the rows and columns.
These are often character vectors, but need not be,
depending on the class of |
colnames and rownames |
return the same values as
|
as.data.frame, matrix, Subscript, nrow, dimnames.
x <- 1:10
y <- list(a=1:10, b=11:20)
is.rectangular(x)
y <- as.rectangular(y)
subscript2d(x,3,1)
subscript2d(y,4,1) <- 55
numRows(x)
numCols(y) <- 3
rowIds(x) <- letters[1:10]
colIds(y)
z <- cbind(1,1:4)
colnames(z)
colnames(z) <- colnames(z)
rownames(z) <- rownames(z)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.