Last data update: 2014.03.03

R: reads data from files into an R data frame.
read_dataR Documentation

reads data from files into an R data frame.

Description

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

Usage

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 <lorenc2@uw.edu>, Timothy P. Jurka <tpjurka@ucdavis.edu>

Examples

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

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(RTextTools)
Loading required package: SparseM

Attaching package: 'SparseM'

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

    backsolve

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/RTextTools/read_data.Rd_%03d_medium.png", width=480, height=480)
> ### Name: read_data
> ### Title: reads data from files into an R data frame.
> ### Aliases: read_data
> ### Keywords: method
> 
> ### ** Examples
> 
> library(RTextTools)
> data <- read_data(system.file("data/NYTimes.csv.gz",package="RTextTools"),type="csv",sep=";")
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>