add read / write from / to csv and move checking directory to helpers
This commit is contained in:
+15
@@ -3,3 +3,18 @@
|
||||
flip <- function(f) function(x, y) f(y, x)
|
||||
|
||||
clear_na <- function(xs) xs[!is.na(xs)]
|
||||
|
||||
check_directory <- function(path, create=F) {
|
||||
# check if download_dir exists
|
||||
if(file.access(path, mode=0) == -1) {
|
||||
if (create) {
|
||||
tryCatch(dir.create(path),
|
||||
error = stop_dir_not_creatable,
|
||||
warning = stop_dir_not_creatable)
|
||||
} else {
|
||||
stop("Directory does not exist. Use create = TRUE if you wish to create the directory.")
|
||||
}
|
||||
} else if (file.access(path, mode=2) == -1) {
|
||||
stop("Directory exists, but is not writeable.")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user