LimaRAF / plantR

An R Package for Managing Species Records from Biological Collections
GNU General Public License v3.0
18 stars 4 forks source link

Improve how fixSpecies() handle unidentified species at the family level with numbers #113

Open LimaRAF opened 2 months ago

LimaRAF commented 2 months ago

Adaptar a função para evitar as anomalias abaixo.

spp <- c("Myrtaceae", "Myrtaceae sp", "Myrtaceae sp.",               
         "Myrtaceae1", "Myrtaceae 1", "Myrtaceae sp.1",
         "Myrcia", "Myrcia1", "Myrcia 1", "Myrcia sp.1", "NC")
plantR::fixSpecies(spp)
plantR::fixSpecies(spp, rm.indet = TRUE)

Sugestão de solução

  check_these <- grepl(" [0-9]+ sp\\.$", toto1$scientificName.new, perl = TRUE)
if (any(check_these))
  toto1$scientificName.new[check_these] <- 
    gsub("(.* )([0-9]+) (sp\\.$)", "\\1\\3\\2", toto1$scientificName.new[check_these], perl = TRUE)