## 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)
Run the code above in your browser using DataLab