Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

matrify

Create Taxon Data.frames From Three Column Database Form


Description

Takes a data.frame in three column form (sample.id, taxon, abundance) and converts it into full matrix form, and then exports it as a data.frame with the appropriate row.names and column names.

Usage

matrify(data)

Arguments

data

a data.frame or matrix in three column format (or database format), where the first column is the sample ID, the second column is the taxon ID, and the third sample is the abundance of that taxon in that sample.

Details

The routine is pure R code to convert data from database form to the sparse matrix form required by multivariate analyses in packages ‘labdsv’ and ‘vegan’, as well as dist and other routines.

Value

A data.frame with samples as rows, taxa as columns, and abundance values for taxa in samples.

Note

Typically, the source of the data will be an ASCII file or a dBase database or a CSV file from an Excel file in three column format. That file can be read into a data.frame with read.table or read.csv and then that data.frame can be matrified by this function.

Author(s)

See Also

Examples

x <- cbind(c('a','a','b','b','b','c','c'),
           c('x','y','x','z','w','y','z'),
           c(1,2,1,3,2,2,1))
matrify(x)

labdsv

Ordination and Multivariate Analysis for Ecology

v2.0-1
GPL (>= 2)
Authors
David W. Roberts <droberts@montana.edu>
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.