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.

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.

References

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

Author

Ananda Mahto

Examples

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 = ",")
#> $`'Experiment Name: Here Be',,` #> V1 V2 V3 #> 1 1 2 3 #> 2 4 5 6 #> 3 7 8 9 #> #> $`'Experiment Name: The Dragons',,` #> V1 V2 V3 #> 1 10 11 12 #> 2 13 14 15 #> 3 16 17 18 #>
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)
#> $`Header: Boston city data` #> Month Data1 Data2 Data3 #> 1 1 1.5 9.1342 8.1231 #> 2 2 12.3 12.3100 1.1290 #> #> $`Header: Chicago city data` #> Month Data1 Data2 Data3 #> 1 1 1.5 9.1342 8.1231 #> 2 2 12.3 12.3100 1.1290 #>