as.rectangular
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 (as.rectangular), or a rectangular data object.
i the first (row) subscript.
j the second (column) subscript.
value the object to be assign to x

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.
Value
as.rectangularreturns x if it is already rectangular, or as.data.frame(x) if it is not.
as.char.recttakes 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.rectangularreturns TRUE if x is rectangular, and FALSE if it is not.
subscript2d(x,i,j)is like x[i,j,drop=F], except that it allows x[,1] (for example) for atomic vectors. Usually, it returns an object of the same class as x (this is not appropriate for some objects, such as "bs" objects). It does not support a drop argument.
numRows and numColsreturn integers, like nrow and ncol, except that they also work on atomic vectors (numRows returns the length of the vector, and numCols returns 1).
rowIds and colIdsreturn the IDs of the rows and columns. These are often character vectors, but need not be, depending on the class of x. They are like the components of dimnames, except that for named vectors, rowIds returns or sets the names and colIds returns NULL.
colnames and rownamesreturn the same values as colIds and rowIds, respectively.
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)
Package splusTimeSeries version 6.0.0-69
Package Index