data(rotifers)
head(rotifers)
## add a column to 'rotifers' with shorter versions of the species names:
if (FALSE) {
rotifers$spcode <- spCodes(rotifers$species, sep.species = "_",
nchar.gen = 1, nchar.sp = 4, nchar.ssp = 0, sep.spcode = ".")
# this produces an error due to resulting species codes not being unique
}
rotifers$spcode <- spCodes(rotifers$species, sep.species = "_",
nchar.gen = 1, nchar.sp = 5, nchar.ssp = 0, sep.spcode = ".")
# with a larger number of characters from the specific name,
# resulting codes are now unique
## check out the result:
head(rotifers)
Run the code above in your browser using DataLab