as.rectangular {splusTimeSeries} | R Documentation |
Uniform Rectangular Data Functions
Description
Functions that allow you to access all rectangular data objects in the same way. Rectangular data objects include matrices, data frames and vectors.
Usage
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
Arguments
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 |
Details
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. Whensubscript2d
is used in an assignment, it does not allow subscript replacement outside the bounds ofx
. Instead, setnumRows
ornumCols
first. When
numRows
ornumCols
is used in an assignment, the row and column IDs are maintained to have the correct length. Usually, this is done by settingnumRows
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<-
andrownames<-
simply callcolIds<-
androwIds<-
, 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
andnumCols
count the number of rows and columns. -
rowIds
andcolIds
(andrownames
andcolnames
) return the row and column names or other identifiers attached to rows and columns. -
colnames
andrownames
return the same values ascolIds
androwIds
, respectively, ifdo.NULL=T
. Instead of using
names
to replace row names from a matrix, userowIds
ordimnames
.The functions
colnames
,rownames
,colnames<-
,rownames<-
emulate R functions of the same names.
Value
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
|
See Also
as.data.frame
, matrix
, Subscript
, nrow
, dimnames
.
Examples
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)