ContactMatrix subsetting | R Documentation |
Methods to subset or combine ContactMatrix objects.
### Subsetting
## S4 method for signature 'ContactMatrix,ANY,ANY'
x[i, j, ..., drop=TRUE]
## S4 replacement method for signature 'ContactMatrix,ANY,ANY,ContactMatrix'
x[i, j] <- value
## S4 method for signature 'ContactMatrix'
subset(x, i, j)
### Combining
## S4 method for signature 'ContactMatrix'
cbind(..., deparse.level=1)
## S4 method for signature 'ContactMatrix'
rbind(..., deparse.level=1)
x |
A ContactMatrix object. |
i, j |
A vector of subscripts, indicating the rows and columns to be subsetted for |
... |
For |
drop |
A logical scalar, ignored by |
value |
A ContactMatrix object with dimensions equal to the length of the two subscripts (or the corresponding dimensions of |
deparse.level |
An integer scalar; see |
Subsetting of ContactMatrix objects behaves like that for standard matrices.
Rows and columns can be selected and rearranged, with concomitant changes to the anchor1
and anchor2
slots.
All subsetting operations will return an ContactMatrix with the specified rows and columns.
However, note that the value of regions
will not be modified by subsetting.
cbind
will combines objects with the same rows but different columns.
Errors will occur if the row regions are not identical between objects (i.e., must have same values in the slots for regions
and anchor1
).
Conversely, rbind
will combines objects with the same columns but different rows.
Again, errors will occur if the columns are not identical (i.e., must have same values in the slots for regions
and anchor2
).
If subsetted anchors are required, see ?"interaction-subset"
for why subsetting should be done before calling the anchors
method.
A subsetted or combined ContactMatrix object.
Aaron Lun
ContactMatrix-class
example(ContactMatrix, echo=FALSE)
# Subsetting:
x[1:5,]
x[,10:15]
x[1:5,10:15]
x2 <- x
x2[1:5,] <- x[6:10,]
as.matrix(x2[,1]) <- 20
# Combining
cbind(x, x)
rbind(x, x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.