subsDT | R Documentation |
A fast data.table
-based alternative to
raster::subs()
.
subsDT(x, dict, by = 1, which = 2, subsWithNA = TRUE, filename = "", ...)
x |
Categorical |
dict |
A |
by |
Vector of one or possibly more integers or character
strings giving the indices or names of the column in
|
which |
Vector of one or possibly more integers or character
strings giving the indices or names of the column in
|
subsWithNA |
Logical. If |
filename |
Character string giving (optional) file name to which the resultant raster should be written. |
... |
Additional arguments as for
|
A RasterLayer
object.
Joshua O'Brien
r <- raster(ncol = 10, nrow = 10) r[] <- round(runif(ncell(r)) * 10) df <- data.frame(id = 2:8, v = c(10, 10, 11, 11, 12:14)) x <- subsDT(r, df) x2 <- subsDT(r, df, subsWithNA = FALSE) df$v2 <- df$v * 10 x3 <- subsDT(r, df, which = 2:3) s <- stack(r, r*3) names(s) <- c("first", "second") x4 <- subsDT(s, df) x5 <- subsDT(s, df, which = 2:3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.