read.mtable: Read Data from a File Containing Multiple Datasets

Description Usage Arguments Value Note Author(s) References Examples

View source: R/read.mtable.R

Description

Sometimes, a single file might have multiple datasets, each separated with a "header" of some sort. This function attempts to read the most basic of those types of files.

Usage

1
read.mtable(inFile, chunkId, ...)

Arguments

inFile

The path to the input file

chunkId

A pattern in the text that identifies the "header" that indicates the start of a new dataset

...

Other arguments to be passed to read.table

Value

A list of data.frames

Note

names are added to the resulting list, but these are not likely to be syntactically valid R names.

Author(s)

Ananda Mahto

References

http://stackoverflow.com/a/11530036/1270695, http://stackoverflow.com/a/11555316/1270695

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
x <- tempfile()
cat("'Experiment Name: Here Be',,", "1,2,3", "4,5,6", "7,8,9",
    "'Experiment Name: The Dragons',,", "10,11,12", "13,14,15",
    "16,17,18", file = x, sep = "\n")

read.mtable(x, "Experi", sep = ",")

cat("Header: Boston city data",
    "Month    Data1    Data2    Data3",
    "1        1.5      9.1342   8.1231",
    "2        12.3     12.31    1.129",
    "", "", "Header: Chicago city data",
    "Month    Data1    Data2    Data3",
    "1        1.5      9.1342   8.1231",
    "2        12.3     12.31    1.129",
    file = x, sep = "\n")

read.mtable(x, "Header", header = TRUE)

mrdwab/SOfun documentation built on June 20, 2020, 6:15 p.m.