Reindent code to use just two spaces

This commit is contained in:
Elias Projahn 2022-05-26 12:42:19 +02:00
parent a1e6147466
commit c04b6337e9
17 changed files with 1583 additions and 1582 deletions

View file

@ -8,25 +8,25 @@
# @param objects A vector of objects that this expression depends on. The hash
# of those objects will be used for identifying the cache file.
cached <- function(name, objects, expr) {
if (!dir.exists("cache")) {
dir.create("cache")
}
if (!dir.exists("cache")) {
dir.create("cache")
}
id <- rlang::hash(objects)
cache_file <- sprintf("cache/%s_%s.rda", name, id)
id <- rlang::hash(objects)
cache_file <- sprintf("cache/%s_%s.rda", name, id)
if (file.exists(cache_file)) {
# If the cache file exists, we restore the data from it.
load(cache_file)
} else {
# If the cache file doesn't exist, we have to do the computation.
data <- expr
if (file.exists(cache_file)) {
# If the cache file exists, we restore the data from it.
load(cache_file)
} else {
# If the cache file doesn't exist, we have to do the computation.
data <- expr
# The results are cached for the next run.
save(data, file = cache_file, compress = "xz")
}
# The results are cached for the next run.
save(data, file = cache_file, compress = "xz")
}
data
data
}
# This is needed to make data.table's symbols available within the package.