Description Usage Arguments Value Author(s) Examples
Only loads an object if the object name is not in the global environment. If not in the global environment and the file exists, the object is loaded (by default). If the file does not exist, the function FUN is run.
1 | checkExists(.name, .path = ".", .FUN, .FUN2, .save.it=TRUE, .load.it, ...)
|
.name |
Character string giving name of object in global environment |
.path |
Path to where the object is saved. |
.FUN |
Function to be executed if <name> is not in the global environment and the file does not exist. |
.FUN2 |
Not currently used. |
.save.it |
Logical. Whether to save the object to the directory indicaged by
|
.load.it |
Logical. If load.it is TRUE, we try to load the object from the
indicated |
... |
Additional arguments passed to FUN. |
Could be anything – depends on what FUN, FUN2 perform.
Future versions could return a 0 or 1 indicating whether the function performed as expected.
R. Scharpf
1 2 3 4 5 6 7 8 9 10 11 12 13 | path <- tempdir()
dir.create(path)
x <- 3+6
x <- checkExists("x", .path=path, .FUN=function(y, z) y+z, y=3, z=6)
rm(x)
x <- checkExists("x", .path=path, .FUN=function(y, z) y+z, y=3, z=6)
rm(x)
x <- checkExists("x", .path=path, .FUN=function(y, z) y+z, y=3, z=6)
rm(x)
##now there is a file called x.rda in tempdir(). The file will be loaded
x <- checkExists("x", .path=path, .FUN=function(y, z) y+z, y=3, z=6)
rm(x)
unlink(path, recursive=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.