subsetIndex | R Documentation |
Extract specific elements from an object.
subsetIndex(object, index, default, ...)
## Default S3 method:
subsetIndex(object, index, default, ...)
## S3 method for class 'matrix'
subsetIndex(object, index, default, col = TRUE, ...)
object |
A vector or a matrix. |
index |
index of the elements to be extracted. 0 indicates that the column should be set to the default value. NA indicates that the column should be set to NA. |
default |
the default value. |
... |
Only used by the generic method. |
col |
If object is a matrix, |
M <- matrix(rnorm(50),5,10)
subsetIndex(M, index = c(0,0,1), default = 0)
subsetIndex(M, index = c(0,2,3,NA), default = 0)
subsetIndex(M, index = c(0,NA,2,3,NA), default = 0)
C <- 1:10
subsetIndex(C, index = c(0,0,1,5,NA), default = 0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.