trans_matrix: Transpose species matrix

View source: R/trans_matrix.R

trans_matrixR Documentation

Transpose species matrix

Description

The function transposes a species matrix, while preserving correct species and sample names. The new column names must be stored as row names of the data frame. They may also be stored in the first column, when chosing the argument row.names = F.

Usage

trans_matrix(matrix, row.names = T, rmchar = FALSE)

Arguments

matrix

Community data, a data frame.

row.names

A logical evaluation indicating whether the new column names are stored as row names of the data frame TRUE (default) or in the first column FALSE.

rmchar

A logical evaluation indicating whether the first character of the original column names should be removed (default: FALSE).

Value

A transposed data frame.

Details

Sometimes vegetation data is organized as a data frame with samples in columns and taxa in rows, with taxon names stored in the first column, e.g. as result of the function merge_taxa. In this case you can use row.names = F to directly convert this species matrix into a statistically analyzable format, e.g. with vegan.

If your dataframe contains prepended “X” to each header due to numbered samples, you can use rmchar = TRUE to remove the first character of the column names during transposing. (You may also avoid this problem at all by using check.names = FALSE when loading the data in read.table)

Author(s)

Friedemann von Lampe (fvonlampe@uni-goettingen.de)

Examples

# Transpose species matrix
schedenveg.trans <- trans_matrix(schedenveg)


fgoral/goeveg documentation built on Feb. 27, 2024, 6:32 a.m.