Adds columns to a traitdata table with standardized trait names and relates them to globally unique identifiers via URIs. Optionally converts units of values and renames factor levels into accepted terms.

standardize.traits(x, thesaurus, rename = NULL, categories = c("No", "Yes"),
  output = "logical", ...)

Arguments

x

a traitdata object (as returned by as.traitdata()) or a data table containing at least the column `scientificName.

thesaurus

an object of class 'thesaurus' (as returned by as.thesaurus()).

rename

a named vector to map user-provided names to thesaurus object names (see Details).

categories

target categories for binary/logical traits harmonization.

output

Details

The function matches the trait names provided in 'traitName' to the traits provided in the thesaurus (in field 'trait'). Matching must be exact (case sensitive). Fuzzy matching may be provided in a later version of the package.

The function parameter 'rename' should be provided to map trait names where user-provided names and thesaurus names are different. In this case, rename should be a named vector with the target names used in the thesaurus as names, and the original names as provided in 'traitName' as value. E.g. renam = c()

Examples

pulldata("carabids")
#> The dataset 'carabids' is now available for use!
dataset1 <- as.traitdata(carabids, taxa = "name_correct", traits = c("body_length", "antenna_length", "metafemur_length"), units = "mm", keep = c(datasetID = "source_measurement", measurementRemark = "note"), metadata = list( bibliographicCitation = attributes(carabids)$citeAs, author = "Fons van der Plas", license = "http://creativecommons.org/publicdomain/zero/1.0/" ) )
#> Input is taken to be a species -- trait matrix. If this is not the case, please provide parameters!
traitlist <- as.thesaurus( body_length = as.trait("body_length", expectedUnit = "mm", valueType = "numeric", identifier = "http://t-sita.cesab.org/BETSI_vizInfo.jsp?trait=Body_length"), antenna_length = as.trait("antenna_length", expectedUnit = "mm", valueType = "numeric", identifier = "http://t-sita.cesab.org/BETSI_vizInfo.jsp?trait=Antenna_length"), metafemur_length = as.trait("metafemur_length", expectedUnit = "mm", valueType = "numeric", identifier = "http://t-sita.cesab.org/BETSI_vizInfo.jsp?trait=Femur_length") ) dataset1Std <- standardize.traits(dataset1, thesaurus = traitlist)
#> Warning: trait value has not been harmonized to standard terms! To perform standardization provide field 'valueType', as well as 'traitUnitStd' and 'factorLevels' for numeric and factorial traits, respectively!
#> Warning: trait value has not been harmonized to standard terms! To perform standardization provide field 'valueType', as well as 'traitUnitStd' and 'factorLevels' for numeric and factorial traits, respectively!
#> Warning: trait value has not been harmonized to standard terms! To perform standardization provide field 'valueType', as well as 'traitUnitStd' and 'factorLevels' for numeric and factorial traits, respectively!
## Example: matching of original names to thesaurus pulldata("heteroptera_raw")
#> loading dataset 'heteroptera_raw' from original data source! #> When using this data, please cite the original publication: #> Gossner MM, Simons NK, Hck L and Weisser WW (2015). Morphometric #> measures of Heteroptera sampled in grasslands across three regions of #> Germany. _Ecology_, *96*, pp. 1154. doi: 10.1890/14-2159.1 (URL: #> http://doi.org/10.1890/14-2159.1). #> The dataset 'heteroptera_raw' is now available for use!
dataset2 <- as.traitdata(heteroptera_raw, taxa = "SpeciesID", traits = c("Body_length", "Antenna_Seg1", "Antenna_Seg2", "Antenna_Seg3", "Antenna_Seg4", "Antenna_Seg5", "Hind.Femur_length"), units = "mm", keep = c(sex = "Sex", references = "Source", lifestage = "Wing_development"), metadata = list( bibliographicCitation = attributes(heteroptera_raw)$citeAs, license = "http://creativecommons.org/publicdomain/zero/1.0/" ) )
#> it seems you are providing repeated measures of traits on multiple specimens of the same species (i.e. an occurrence table)! Sequential identifiers for the occuences will be added. If your dataset contains user-defined occurrenceIDs you may specify the column name in parameter 'occurrences'.
dataset2 <- mutate.traitdata(dataset2, antenna_length = Antenna_Seg1 + Antenna_Seg2 + Antenna_Seg3 + Antenna_Seg4 + Antenna_Seg3 ) traits2 <- as.thesaurus( body_length = as.trait("body_length", expectedUnit = "mm", valueType = "numeric", identifier = "http://t-sita.cesab.org/BETSI_vizInfo.jsp?trait=Body_length"), antenna_length = as.trait("antenna_length", expectedUnit = "mm", valueType = "numeric", identifier = "http://t-sita.cesab.org/BETSI_vizInfo.jsp?trait=Antenna_length"), metafemur_length = as.trait("metafemur_length", expectedUnit = "mm", valueType = "numeric", identifier = "http://t-sita.cesab.org/BETSI_vizInfo.jsp?trait=Femur_length") ) dataset2Std <- standardize.traits(dataset2, thesaurus = traits2, rename = c(Body_length = "body_length", antenna_length = "antenna_length", Hind.Femur_length = "metafemur_length" ) )
#> Warning: trait value has not been harmonized to standard terms! To perform standardization provide field 'valueType', as well as 'traitUnitStd' and 'factorLevels' for numeric and factorial traits, respectively!
#> Warning: trait value has not been harmonized to standard terms! To perform standardization provide field 'valueType', as well as 'traitUnitStd' and 'factorLevels' for numeric and factorial traits, respectively!
#> Warning: trait value has not been harmonized to standard terms! To perform standardization provide field 'valueType', as well as 'traitUnitStd' and 'factorLevels' for numeric and factorial traits, respectively!