Skip to contents

Loads trait data and sets species names as row names. If a CSV path is supplied, it is read with read.csv. All species identifiers must be present and unique because row names identify one trait row per species. For repeated observations, use read.csv() and pass the resulting data frame with species_col to check_pigauto() and impute(). By default, all non-species columns are returned (numeric, factor, integer, etc.). Use trait_cols to select a subset.

Usage

read_traits(
  x,
  species_col = "species",
  trait_cols = NULL,
  factor_cols = NULL,
  ordered_cols = NULL
)

Arguments

x

character path to a CSV file, or a data.frame.

species_col

character. Name of the column containing species names (default "species").

trait_cols

character vector of column names to include. If NULL (default), all columns except species_col are used.

factor_cols

character vector of columns to coerce to factor.

ordered_cols

character vector of columns to coerce to ordered.

Value

A data.frame with unique species names as row names.

Examples

df <- data.frame(species = c("Sp_a", "Sp_b"), mass = c(10, 20))
traits <- read_traits(df, species_col = "species")