# NOT RUN {
r1 <- raster(nrow=10, ncol=10)
values(r1) <- runif(ncell(r1))
plot(r1)
# after running the following line, click on the map twice
e <- drawExtent()
# after running the following line, click on the map twice
mean(values(crop(r1, drawExtent())))
# }
Run the code above in your browser using DataLab