combine_text_files: Combine Text File Contents into a Single File

Description Usage Arguments Use Cases

View source: R/file_management.R

Description

Read text from a list of files with names matching a pattern, combine into a single output file. An error will be thrown if the output file already exists.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
combine_text_files(
  path = ".",
  pattern,
  output_file,
  separator = "\n\n\n\n\n",
  remove_files = FALSE,
  all.files = FALSE,
  recursive = FALSE,
  ignore.case = FALSE,
  include.dirs = FALSE,
  no.. = FALSE
)

Arguments

path

a character vector of full path names; the default corresponds to the working directory, getwd(). Tilde expansion (see path.expand) is performed. Missing values will be ignored. Elements with a marked encoding will be converted to the native encoding.

pattern

an optional regular expression. Only file names which match the regular expression will be returned.

output_file

Path to a file that combined files will be written to. This file will not be overwritten if it already exists.

separator

Pattern that separates the text from the other files in the combined output.

remove_files

If TRUE, removes each file after it is appended to the 'output_file'. Defaults to FALSE.

all.files

a logical value. If FALSE, only the names of visible files are returned. If TRUE, all file names will be returned.

recursive

logical. Should the listing recurse into directories?

ignore.case

logical. Should pattern-matching be case-insensitive?

include.dirs

logical. Should subdirectory names be included in recursive listings? (They always are in non-recursive ones).

no..

logical. Should both "." and ".." be excluded also from non-recursive listings?

Use Cases

In R package file management, sometimes R directory files need to be grouped into function families. This can be done by using this function to first write the group of functions to a new file.


patelm9/cave documentation built on March 29, 2021, 6:28 p.m.