| get_if_not_exists | R Documentation |
Download a file if it doesn't already exist
get_if_not_exists(x, destfile, read_function = readRDS, ow = FALSE, ...)
x |
url string or function to be evaluated |
destfile |
file.path |
read_function |
function to read existing files, defaults to readRDS |
ow |
logical force overwrite |
... |
parameters passed to x |
## Not run:
# unlink("data.gz")
get_if_not_exists("http://www.omegahat.net/RCurl/data.gz", "data.gz", ow = TRUE)
junk_rds <- function(destfile, add_number){
saveRDS(1 + add_number, destfile)
return(1 + add_number)
}
# unlink("junk.rds")
x <- get_if_not_exists(junk_rds, "junk.rds", add_number = 1)
junk_csv <- function(destfile, add_number){
write.csv(1 + add_number, destfile, row.names = FALSE)
return(1 + add_number)
}
# unlink("junk.csv")
x <- get_if_not_exists(junk_csv, "junk.csv", read.csv, add_number = 1)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.