| cache.clean | R Documentation |
Functions in the package include options to write files to a cache directory,
set up with the cache.setup() function.
Obsoletely files might be created if the name parameter in a function call
is changed or if a function call is no longer being used.
The cache.clean() function provides a way to find files that have not be
modified in the last older_than days and lists the files for the user to
agree to delete or not.
cache.clean(older_than = NULL, interactive = TRUE)
older_than |
A positive number indicating number of days (fractions allowed).
Files with older modification times than this will be deleted
after confirmation if |
interactive |
Logical.
|
The function is interactive if run in an interactive session with
interctive = TRUE.
In addition to deleting old files, the function will also optionally delete
empty directories and, if the top level cache directory is also empty,
then it will also optionally delete the cache directory and unset it.
The latter will only be done in interactive sessions with
interactive = TRUE to avoid breaking non-interactive code.
One way to clean only unused files is to run all current code and then
run cache.clean() with older_than set to something greater than the
number of days it takes for the code to run and less than when the code was
previously run. For example, if your code takes 5 minutes to run and you
previously ran it 2 days ago, you could run all your code and, when it has
finished, use cache.clean(older_than = 1).
NULL (invisibly). Primarily called to clean up the cache directory.
cache.setup()
# Setup a cache directory
cache.setup()
# Now code with check = TRUE or save_out = TRUE will work, e.g.,
# Create CFA keys
keys0 <- c("grit_c", "grit_p", "hope_a", "hope_p")
keys <- sapply(
keys0, function(x) names(BFIGritHope)[grep(x, names(BFIGritHope))]
)
# Run models
cfa_fit <- cfa.from.keys(
keys, BFIGritHope, fit_save = TRUE, check = TRUE, save_out = TRUE
)
# Check that they are not estimated again.
cfa_fit <- cfa.from.keys(
keys, BFIGritHope, fit_save = TRUE, check = TRUE, save_out = TRUE
)
cache.clean(60/86400) # Delete files not modified in the last minute.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.