process.folder: Apply a set of procedures to all files in a folder

Description Usage Arguments Details Value

View source: R/accelerate-summarize.R

Description

process.folder

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
process.folder(
  FOLDER,
  FUN,
  FUN2 = NULL,
  SAVE1 = NULL,
  SAVE2 = NULL,
  FINALLY = NULL,
  LIST = NULL,
  EXT = NULL,
  PATTERN = "",
  ALL = FALSE,
  FULL = TRUE,
  VERBOSE = TRUE,
  FILES = NULL,
  TIME = TRUE,
  ...
)

Arguments

FOLDER

(character) name of a folder

FUN

a function

FUN2

a funciton

SAVE1

a function

SAVE2

a function

FINALLY

a function

LIST

a vector (numeric or logical) of files to include

EXT

file extension(s) to include

PATTERN

(character) pattern of file names - passed to list.files

ALL

(boolean) include all files in the folder?

FULL

(boolean) use full names

VERBOSE

(boolean) report all the superfluous details?

FILES

(character vector) a set of files possibly from different folders; if not NULL then the FOLDER argument is ignored

TIME

(boolean) sets timing on/off

...

...

Details

This applies a set of rules to all (or some: as per LIST) files in a folder (with the same extensions, specified in EXT). FUN is first applied to each file (using try), and then FUN2. Errors are collected and reported as the component $errors in the result. Finally, the function given in FINALLY is applied to combine the results (using do.call). For saving the results, specify a function in SAVE. Finally, the results are timed if TIME==TRUE. See read.actigraph.folder for an example.

Value

process.folder


lebatsnok/accelerate documentation built on Dec. 21, 2021, 9:47 a.m.