Closed Jegelewicz closed 3 years ago
Can you please share code snippet / complete function call.
library(taxotools)
# if no genus, but scientificName need to parse scientificName
df <- melt_scientificname (df,
sciname = "scientificName",
genus = "genus",
species = "specificEpithet",
subspecies = "infraspecificEpithet",
author = "scientificNameAuthorship")
Let me start this one over, because actually when I try to use:
library(taxotools)
df <- cast_scientificname (df,
genus = "genus",
subgenus = "subgenus",
species = "species",
subspecies = "subspecies",
author = "scientificNameAuthorship")
I get this error
Error in cast_scientificname(df, genus = "genus", subgenus = "subgenus", : could not find function "cast_scientificname"
I made sure to have taxotools library loaded.
I took this part of the code
for(i in 1:nrow(newdat)){
if(!is.empty(newdat$genus_[i])){
scn <- toproper(newdat$genus_[i])
}
if(!is.empty(newdat$subgenus_[i])){
scn <- paste(scn," (",toproper(newdat$genus_[i]),") ",sep = "")
}
if(!is.empty(newdat$species_[i])){
scn <- paste(scn,newdat$species_[i])
}
if(!is.empty(newdat$subspecies_[i])){
scn <- paste(scn,newdat$subspecies_[i])
}
if(!is.empty(newdat$author_[i])){
scn <- paste(scn,trimws(newdat$author_[i]))
}
newdat$sciname_[i] <- scn
I made a few changes, but it works for me like this
df$scientificName[i] <- for(i in 1:nrow(df)){
if(!is.na(df$genus[i])){
scn <- df$genus[i]
}
if(!is.na(df$subgenus[i])){
scn <- paste(scn," (",df$subgenus[i],")",sep = "")
}
if(!is.na(df$specificEpithet[i])){
scn <- paste(scn,df$specificEpithet[i], sep = " ")
}
if(!is.na(df$infraspecificEpithet[i])){
scn <- paste(scn,df$infraspecificEpithet[i], sep = " ")
}
if(!is.na(df$scientificNameAuthorship[i])){
scn <- paste(scn,trimws(df$scientificNameAuthorship[i]), sep = " ")
}
df$scientificName[i] <- scn
}
I think this was just due to trying to run single function rather than installing the package again.
@vijaybarve when I try to use the cast_scientificname function, I get this:
Any idea what I am missing?