View source: R/cast.traitdata.R
cast.traitdata | R Documentation |
Function to reformat trait data from the long-table into a matrix/wide-table or occurrence table format.
cast.traitdata( .data, values = "verbatimTraitValue", traits = "verbatimTraitName", units = "verbatimTraitUnit", fun.aggregate = NULL )
.data |
dataset of class 'traitdata' to be cast into wide-table format. |
values |
the column name containing the trait values to be used to fill
the matrix (default is |
traits |
the column name to be kept for parsing into wide-table (default
is |
units |
the column name containing the units of numerical values
(default is |
fun.aggregate |
option for |
The wide-table will be composed while preserving the detail given in the dataset (occurrence level or taxa level). The cells will be filled with the values from 'verbatimTraitValue'.
If taxa should be summarized, provide function for summarizing in parameter
'summarize'. This can be any function that takes a vector and returns a
single value for both numerical and factorial/character input vectors!.
The default for numerical values is to return an arithmetric mean while
including any outliers. For factorial values, the value is accepted if it
is equal in all of the input entries. Otherwise NA is returned. For
heterogeneous factorial or character input, user action is required for
homogenizing the data before calling cast.traitdata()
.
a wide-table data.frame object containing all taxa (and other differentiating parameters) in rows and all traits (extracted from column 'verbatimTraitName') in columns.
The function is currently not able to handle
multiple columns of trait data (incl. names and units). Those are currently
omitted from the output and may be added manually. You can alter the
columns to be used to construct the matrix by specifying those in
parameters traits
, values
, and units
. Automatic handling of the Std
columns might be added at a later stage.
pulldata("arthropodtraits") head(arthropodtraits) dataset3 <- as.traitdata(arthropodtraits, taxa = "SpeciesID", traits = c("Body_Size", "Dispersal_ability", "Feeding_guild","Feeding_guild_short", "Feeding_mode", "Feeding_specialization", "Feeding_tissue", "Feeding_plant_part", "Endophagous_lifestyle", "Stratum_use", "Stratum_use_short"), units = c(Body_Size = "mm"), keep = c(measurementRemark = "Remark"), metadata = as.metadata( license = "http://creativecommons.org/publicdomain/zero/1.0/" ) ) head(dataset3) dd3 <-cast.traitdata(dataset3) head(dd3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.