path.batchApply: Process The Files and Sub-Directories in a Directory...

Description Usage Arguments Value See Also

View source: R/batchApply.R

Description

The sub-folders under a given path are iteratively processed. For each folder, the function check.directory returns either TRUE if we should investigate it (recursively) or FALSE, if we should ignore it. By default we assume TRUE. Files in a folder can either be processed one-by-one (via file.single) or all together (via file.in.folder). Both file.single and file.in.folder are environments. The names in these environments are regular expressions which are matched against the files in the folders. The values are handler methods of the type function(root, path(s)). (paths for file.in.folder, path for file.single). These handlers are applied to all the single files (file.single) or the list of files in a folder (file.in.folder) that match to their names. The names could, e.g., be regular expressions matching to file extensions created by path.extensionRegExp.

The processing can either take place sequentially (for values of core<=1L) or in parallel (cores>1L). In the latter case, we first gather all handler applications that need to be done and then pass them to mclapply.

This function is not supposed to return anything useful. Instead, the idea is that the handlers would read their input files and create output files storing their result.

Usage

1
2
3
path.batchApply(path = getwd(), file.single = emptyenv(),
  file.in.folder = emptyenv(), check.directory = NULL, cores = 1L,
  logging = FALSE)

Arguments

path

the path to explore recursively

file.single

an environment or named list with file consumers of the form function(root, path), where root will be the normalized root path (path) and path the path to a file whose name matches to the regular expression provided as name of consumer

file.in.folder

an environment or named list with file consumers of the form function(root, paths), where root will be the normalized root path (path) and paths is the array of the paths of all files in a folder whose name matches to the regular expression provided as name of consumer

check.directory

a function of the form function(root, path) which returns TRUE if we should recurse into the directory path and false if not

cores

the number of cores to use. If cores <= 1L, the consumers are applied sequentially. For cores>1L, we use the mclapply function provided by the parallel package to invoke all the consumers with the specified number of cores

logging

the logging setup, see makeLogger

Value

an unnamed and recursively unlisted vector of the results of all the processors, with no pre-defined order

See Also

path.extensionRegExp


thomasWeise/utilizeR documentation built on May 30, 2019, 11:48 a.m.