read_dir: Read In Multiple Files From a Directory

Description Usage Arguments Value Examples

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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

1
2
3
4
5
## Not run: 
read_dir(system.file("docs/Maas2011/pos", package = "textreadr"))
read_dir(system.file("docs/Maas2011", package = "textreadr"), recursive=TRUE)

## End(Not run)

Example output

Table: [20 x 2]

   document content                                 
1  0_9      Bromwell High is a cartoon comedy. It ra
2  1_7      If you like adult comedy cartoons, like 
3  10_9     I'm a male, not given to women's movies,
4  11_9     Liked Stanley & Iris very much. Acting w
5  12_9     Liked Stanley & Iris very much. Acting w
6  13_7     The production quality, cast, premise, a
7  14_10    This film has a special place in my hear
8  15_7     I guess if a film has magic, I don't nee
9  16_7     I found this to be a so-so romance/drama
10 17_9     This is a complex film that explores the
.. ...      ...                                      
Table: [40 x 2]

   document content                                 
1  0_3      Story of a man who has unnatural feeling
2  1_1      Robert DeNiro plays the most unbelievabl
3  10_2     This film had a lot of promise, and the 
4  11_3     If you look at Corey Large's information
5  12_1     All I could think of while watching this
6  13_2     Weak plot, predictable violence, only se
7  14_2     There are times when finishing a film on
8  15_1     This is it. This is the one. This is the
9  16_3     There are lots of extremely good-looking
10 17_3     Nine minutes of psychedelic, pulsating, 
.. ...      ...                                      

textreadr documentation built on Oct. 9, 2021, 5:06 p.m.