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) <- valueas.rectangular), or a
rectangular data object.xas.rectangularx if it is already rectangular, or
as.data.frame(x) if it is not.as.char.rectis.rectangularTRUE if x is rectangular, and FALSE if it is not.subscript2d(x,i,j)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 numColsnrow and ncol,
except that they also work on atomic vectors (numRows returns
the length of the vector, and numCols returns 1).rowIds and colIdsx.
They are like the components of dimnames,
except that for named vectors, rowIds returns or sets the names
and colIds returns NULL.colnames and rownamescolIds and rowIds, respectively.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.subscript2dis for subscripting. Whensubscript2dis used in an assignment, it does not allow subscript replacement
outside the bounds ofx. Instead, setnumRowsornumColsfirst.numRowsornumColsis used in
an assignment, the row and column IDs are maintained
to have the correct length. Usually, this is done by settingnumRowson the ID vector,
but for some objects (for example, data frames)
this might not be appropriate, and they have their own methods.colnames<-andrownames<-simply callcolIds<-androwIds<-, respectively.as.rectangularconverts any object to a rectangular
data object (usually a data frame), if possible.is.rectangulartests whether an object is rectangular.numRowsandnumColscount the number of rows and columns.rowIdsandcolIds(andrownamesandcolnames) return the row and column names or other
identifiers attached to rows and columns.colnamesandrownamesreturn the same values ascolIdsandrowIds, respectively, ifdo.NULL=T.namesto replace row names from a matrix,
userowIdsordimnames.colnames,rownames,colnames<-,rownames<-emulateRfunctions of the same names.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)Run the code above in your browser using DataLab