read_data: reads data from files into an R data frame.

Description Usage Arguments Value Author(s) Examples

View source: R/read_data.R

Description

Reads data from several types of data storage types into an R data frame.

Usage

1
read_data(filepath, type=c("csv","delim","folder"), index=NULL, ...)

Arguments

filepath

Character string of the name of the file or folder, include path if the file is not located in the working directory.

type

Character vector specifying the file type. Options include csv, delim, and folder to denote .csv files, delimited files (tab, pipe, etc.) files, or folders of text files. If using the delim option, be sure to pass in a separate sep parameter to indicate how the file is delimited.

index

The path to a CSV file specifying the training label of each file in the folder of text files, one per line. An example of one line would be 1.txt,1. Do not include the full file path for each file, that will be handled automatically using the folder location passed into filepath. This index file must be located outside the folder of files.

...

Other arguments passed to R's read.csv function.

Value

An data.frame object is returned with the contents of the file.

Author(s)

Loren Collingwood, Timothy P. Jurka

Examples

1
2
library(RTextTools)
data <- read_data(system.file("data/NYTimes.csv.gz",package="RTextTools"),type="csv",sep=";")

Example output

Loading required package: SparseM

Attaching package: 'SparseM'

The following object is masked from 'package:base':

    backsolve

RTextTools documentation built on April 26, 2020, 9:05 a.m.