# NOT RUN {
a <- 2
tmpfile1 <- tempfile()
tmpfile2 <- tempfile()
save(a, file = tmpfile1)
save(a, file = tmpfile2)
# treats as character string, so 2 filenames are different
digest::digest(tmpfile1)
digest::digest(tmpfile2)
# tests to see whether character string is representing a file
.robustDigest(tmpfile1)
.robustDigest(tmpfile2) # same
# if you tell it that it is a path, then you can decide if you want it to be
# treated as a character string or as a file path
.robustDigest(asPath(tmpfile1), quick = TRUE)
.robustDigest(asPath(tmpfile2), quick = TRUE) # different because using file info
.robustDigest(asPath(tmpfile1), quick = FALSE)
.robustDigest(asPath(tmpfile2), quick = FALSE) # same because using file content
# Rasters are interesting because it is not know a priori if it
# it has a file name associated with it.
library(raster)
r <- raster(extent(0,10,0,10), vals = 1:100)
# write to disk
r1 <- writeRaster(r, file = tmpfile1)
r2 <- writeRaster(r, file = tmpfile2)
digest::digest(r1)
digest::digest(r2) # different
digest::digest(r1)
digest::digest(r2) # different
.robustDigest(r1)
.robustDigest(r2) # same... data are the same in the file
# note, this is not true for comparing memory and file-backed rasters
.robustDigest(r)
.robustDigest(r1) # different
# }
Run the code above in your browser using DataLab