replace Cmd (macOS) by Ctrl for PC
url <- "https://rworkshop.uni.lu/lectures/data/example.csv"
url_file <- here::here("data", basename(url))
url_file
## [1] "/builds/aurelien.ginolhac/rworkshop/data/example.csv"
# download if file is not present
if (!file.exists(url_file)) {
message(paste("downloading", url, "to", url_file))
download.file(url, url_file)
}
## downloading https://rworkshop.uni.lu/lectures/data/example.csv to /builds/aurelien.ginolhac/rworkshop/data/example.csv
## Warning in download.file(url, url_file): URL https://rworkshop.uni.lu/lectures/
## data/example.csv: cannot open destfile '/builds/aurelien.ginolhac/rworkshop/
## data/example.csv', reason 'No such file or directory'
## Warning in download.file(url, url_file): download had nonzero exit status
message("testing again, no download this time")
## testing again, no download this time
if (!file.exists(url_file)) {
message(paste("downloading", url, "to", url_file))
download.file(url, url_file)
}
## downloading https://rworkshop.uni.lu/lectures/data/example.csv to /builds/aurelien.ginolhac/rworkshop/data/example.csv
## Warning in download.file(url, url_file): URL https://rworkshop.uni.lu/lectures/
## data/example.csv: cannot open destfile '/builds/aurelien.ginolhac/rworkshop/
## data/example.csv', reason 'No such file or directory'
## Warning in download.file(url, url_file): download had nonzero exit status
install.packages()
in un-commented line or in a chunk not tagged as eval = FALSE
library()
calls of necessary package. You can use as first chunk with include = FALSE
to avoid loading messages but loading all necessary packageshere
and relative paths to have a share-able project