Detailed description |
Have you ever considered adding a feature such that functions recognize that if overwrite=FALSE and the data they were about to attempt to write already exists then the function should short-circuit to returning the object as if the operation had been performed?
I often find myself doing iterative development where I want to reinstantiate all of the preceding objects in a new R session without actually performing all of the calculations. Sure, saving an image would address this, but it doesn't always happen in time. I often find myself using constructs like this:
overwriteRasters <- FALSE # global "option"
someRasterObj <-
if( overwriteRasters) {
someRasterFunction(
inputRaster,
filename= "foo.tif",
overwrite= TRUE)
} else {
raster( "foo.tif")
}
This is a completely contrived example, obviously, but I think it conveys what I am trying to describe. WIth some effort it probably could be abstracted as a wrapper but some logic to decide when brick() might be needed instead of raster(), or maybe an extra arg, but it seems like it could be hidden away altogether. What do you think? |
|