dirApply: Apply a function over files in directory.

Description Usage Arguments Details

Description

The function (f) will be applied to the files in a directory (in a lapply/sapply/vapply-style).

Usage

1
2
3
dirApply(f, sourceDir, targetDir = NULL, pattern = NULL, mc = FALSE,
  progress = TRUE, verbose = FALSE, sample = FALSE, filenames = NULL,
  continue = FALSE, failsafe = FALSE, param = list())

Arguments

f

function that will be applied to all files in sourceDir

sourceDir

source directory with files to be processed

targetDir

target directory where the processed files will be saved

pattern

pattern (can be a regex) that will be used by list.files as 'pattern'-argument

mc

logical, whether to use multicore/parallel processing, if numeric, the number of cores to use

progress

logical, whether to show progress bar

verbose

logical, whether to be verbose

sample

defults to FALSE, if a numeric, a number of random files to process

filenames

character vector with filenames to be used, a subset of files in sourceDir

continue

work only on those files not yet present in target dir

failsafe

whether to be robust and catch errors using try, available only without parallelisation

param

a list with parameters to be passed to the function f

Details

Function f passes in a function that will be applied to the individual files in the source directory (sourceDir). The function needs to conform to a standardized format, parameters required are "filename" (character), "sourceDir" (character), "targetDir" (character) and "param" (list).

The function f can be applied in a multicore mode. If progress is FALSE, then mclapply will be used. If progress is TRUE, pblapply from the package pbapply will be used.


PolMine/ctk documentation built on May 8, 2019, 3:20 a.m.