| assignspp | R Documentation |
Assigns species botanical attributes to a dataset,
based upon a reference column (refcol). The attributes can be
any of the fields available in the spplist dataframe,
such as: spp.ci.name (genus and epitetus name of the species),
spp.name (common name), and spp.ci.abb
(abbreviated scientific name).
assignspp(
data,
attri = c("spp.name", "spp.ci.name"),
refcol = "sppcode",
all.x = TRUE,
attri.all = FALSE,
...
)
data |
A dataframe where to assign the species information. |
attri |
A string vector having the attributes of the species
to be assigned from the species list contained in spplist.
This vector, by default, has two attributes: |
refcol |
A string having the common column name to be used for
linking both the dataset and the species list. In
spplist, all the attributes available for the species
list are detailed, showing all the information that can be joined
to the dataset. Notice that the |
all.x |
Whether to preserve not finded values ( |
attri.all |
By default is set to |
... |
Other options for controlling the |
A dataframe object including the attributes defined in
the parameter attri.
spplist and base::merge().
## example data frame
myData <- data.frame(narb = c(1, 2, 3),
sppcode = c("nob", "np", "nd"),
dbh = c(20, 14, 23))
myData
## assign common, scientific and abbreviated name, based on `esp` value (default)
assignspp(myData)
## Assign more than one attribute based on common name
## just to remember, adding a single attribute (different from the default)
assignspp(myData, attri = "spp.ci.name")
## now, a more real example
newData <- assignspp(myData, attri = c("spp.name","genus","spp.ci.abb"))
newData
## by default this function preserve names not found in biometrics::spplist
missingData <- rbind(myData, c(4, "notFoundData", 30))
missingData
assignspp(missingData, attri = "spp.name")
##the latter can be modified with option `all.x` of the `merge()` function
assignspp(missingData, attri = "spp.name", all.x = FALSE)
## In the case of wanting all the attributes to be merged, set option
## `attri.all` to `TRUE`, which willl overwrite the vector `attri`.
assignspp(missingData, attri = "spp.name", attri.all=TRUE, all.x =
FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.