check_files {assertable}R Documentation

Check for the existence of a vector of files, optionally repeated for a set amount of time.

Description

Given a character vector of filenames, check how many of them currently exist. Optionally, can keep checking for a specified amount of time, at a given frequency

Usage

check_files(filenames, folder = "", warn_only = FALSE,
  continual = FALSE, sleep_time = 30, sleep_end = (60 * 3),
  display_pct = 75)

Arguments

filenames

A character vector of filenames (specify full paths if you are checking files that are not in present working directory)

folder

An optional character containing the folder name that contains the files you want to check (if used, do not include folderpath in the filenames characters). If not specified, will search in present working directory.

warn_only

Boolean (T/F), whether to end with a warning message as opposed to an error message if files are still missing at the end of the checks.

continual

Boolean (T/F), whether to only run once or to continually keep checking for files for sleep_end minutes. Default = F.

sleep_time

numeric (seconds); if continual = T, specify the number of seconds to wait in-between file checks. Default = 30 seconds.

sleep_end

numeric (minutes); if continual = T, specify number of minutes to check at sleep_time intervals before terminating. Default = 180 minutes.

display_pct

numeric (0-100); at what percentage of files found do you want to print the full list of still-missing files? Default = 75 percent of files.

Value

Prints the number of files that match. If warn_only = T, returns a character vector of missing files

Examples

## Not run: 
 for(i in 1:3) {
   data <- CO2
   data$id_var <- i
   write.csv(data,file=paste0("file_",i,".csv"),row.names=FALSE)
 }
 filenames <- paste0("file_",c(1:3),".csv")
 check_files(filenames)

## End(Not run)

[Package assertable version 0.2.8 Index]