multiread {ngram}R Documentation

Multiread

Description

Read in a collection of text files.

Usage

multiread(
  path = ".",
  extension = "txt",
  recursive = FALSE,
  ignore.case = FALSE,
  prune.empty = TRUE,
  pathnames = TRUE
)

Arguments

path

The base file path to search.

extension

An extension or the "*" wildcard (for everything). For example, to read in files ending .txt, you could specify extension="txt". For the purposes of this function, each of *.txt, *txt, .txt, and txt are treated the same.

recursive

Logical; should the search include all subdirectories?

ignore.case

Logical; should case be ignored in the extension? For example, if TRUE, then .r and .R files are treated the same.

prune.empty

Logical; should empty files be removed from the returned list?

pathnames

Logical; should the full path be included in the names of the returned list.

Details

The extension argument is not a general regular expression pattern, but a simplified pattern. For example, the pattern *.txt is really equivalent to *[.]txt$ as a regular expression. If you need more complicated patterns, you should directly use the dir() function.

Value

A named list of strings, where the names are the file names.

Examples

## Not run: 
path = system.file(package="ngram")

### Read all files in the base path
multiread(path, extension="*")

### Read all .r/.R files recursively (warning: lots of text)
multiread(path, extension="r", recursive=TRUE, ignore.case=TRUE)


## End(Not run)


[Package ngram version 3.2.3 Index]