readFile: Read a file to a data frame.

Description Usage Arguments Value Examples

Description

If the file extension is csv, then use read.csv, otherwise use read.table.

Usage

1
2
3
readFile(file, sep = "\t", header = TRUE, row.names = 1,
  verbose = TRUE, msg.file = "file", msg.col = "columns",
  msg.row = "rows", ...)

Arguments

file

The 1st row is column names, the 1st column is row names.

sep

Only used for non csv file. Default to tab "\t".

header

A logical value indicating whether the file contains the names of the variables as its first line. Default to TRUE.

row.names

A vector of row names. This can be a vector giving the actual row names, or a single number giving the column of the table which contains the row names, or character string giving the name of the table column containing the row names. If there is a header and the first row contains one fewer field than the number of columns, the first column in the input is used for the row names. Otherwise if row.names is NULL, the rows are numbered. Default to 1. Using row.names = NULL forces row numbering.

verbose

More details. Default to TRUE.

msg.file, msg.col, msg.row

The message regarding file, column and row, if verbose=TRUE.

...

Other arguments passed to read.table.

Value

A data frame from the file, such as

OTU_id plot01 plot02 ...
OTU_1 1 0 ...
OTU_2 100 200 ...
OTU_3 56 3 ...

Examples

1
2
3
4
community.matrix <- readFile("16S.txt", msg.file="16S OTU table", msg.col="samples", msg.row="OTUs")
taxa.table <- readFile("16S_taxonomy_table.txt", msg.file="16S taxonomy table", msg.row="OTUs")
env <- readFile("env_data.txt", msg.file="enviornmental data", msg.row="samples")
taxa.phyla <- readFile("taxonomy97phyla.txt", row.names=NULL)

walterxie/ComMA documentation built on May 3, 2019, 11:51 p.m.