Learn R Programming

fuzzySim (version 2.0)

transpose: Transpose (part of) a matrix or dataframe

Description

This function transposes (a specified part of) a matrix or data frame, optionally using one of its columns as column names for the transposed result. It can be useful for turning a species presence-absence table into a regional species composition table.

Usage

transpose(data, sp.cols = 1:ncol(data), reg.names = NULL)

Arguments

data

a matrix or data frame containing the species occurrence data to transpose.

sp.cols

names or index numbers of the columns containing the species occurrences in data which are meant to be transposed.

reg.names

name or index number of the column in data containing the region names, to be used as column names in the transposed result.

Value

This function returns the transposed sp.cols of data, with the column specified in reg.names as column names.

See Also

t

Examples

Run this code
# NOT RUN {
data(rotif.env)

head(rotif.env)

names(rotif.env)

rotif.reg <- transpose(rotif.env, sp.cols = 18:47, reg.names = 1)

head(rotif.reg)
# }

Run the code above in your browser using DataLab