Learn R Programming

textreadr (version 1.2.0)

read_dir: Read In Multiple Files From a Directory

Description

Read in multiple files from a directory and create a base::data.frame().

Usage

read_dir(
  path,
  pattern = NULL,
  doc.col = "document",
  all.files = FALSE,
  recursive = FALSE,
  ignore.case = FALSE,
  verbose = FALSE,
  ...
)

Arguments

path

Path to the directory.

pattern

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

doc.col

A string naming the document columns (i.e., file names sans file extension).

all.files

Logical. 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. If TRUE case in the pattern argument will be ignored.

verbose

Logical. Should Each iteration of the read-in be reported.

...

Other arguments passed to read_document functions.

Value

Returns a base::data.frame() with file names as a document column and content as a text column.

Examples

Run this code
# NOT RUN {
read_dir(system.file("docs/Maas2011/pos", package = "textreadr"))
read_dir(system.file("docs/Maas2011", package = "textreadr"), recursive=TRUE)
# }

Run the code above in your browser using DataLab