# NOT RUN {
r <- raster(ncol=10, nrow=10)
values(r) <- round(runif(ncell(r)) * 10)
df <- data.frame(id=2:8, v=c(10,10,11,11,12:14))
x <- subs(r, df)
x2 <- subs(r, df, subsWithNA=FALSE)
df$v2 <- df$v * 10
x3 <- subs(r, df, which=2:3)
s <- stack(r, r*3)
names(s) <- c('first', 'second')
x4 <- subs(s, df)
x5 <- subs(s, df, which=2:3)
# }
Run the code above in your browser using DataLab