Function to reformat trait data from the long-table into a matrix/wide-table or occurrence table format.
1 2 3 4 5 6 7
dataset of class 'traitdata' to be cast into wide-table format.
the column name containing the trait values to be used to fill
the matrix (default is
the column name to be kept for parsing into wide-table (default
the column name containing the units of numerical values
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
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
units. Automatic handling of the
columns might be added at a later stage.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
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.