Closed johnbaums closed 9 years ago
Good suggestion.
(I'm often caught - in R more generally - with factors where I wanted strings. I'm never game to set options(stringsAsFactors=FALSE)
globally because I'm sure there's plenty of code that relies on the default TRUE setting for this.)
Can you give an example please? I'm obviously missing something, because I don't see factors in the output from search_names
.
Thanks ...
Ah, sorry - I was unclear... I was referring to factor input.
dat <- read.table(text='species
Burramys parvus
Cygnus atratus', sep='\n', header=TRUE)
search_names(dat$species)
## Error: taxa is not a character vector
Done in v1.12 (in functions search_names
, species_info
, taxinfo_download
, occurrences
, and search_fulltext
)
> search_names(factor("Burramys parvus"))
searchTerm name commonName rank
1 "Burramys parvus" "Burramys parvus" " Broom's Pygmy-possum, Burramys, Mountain Pygmy Possum, Mountain Pygmy-possum" "species"
guid
1 "urn:lsid:biodiversity.org.au:afd.taxon:3f17cf84-982a-48f2-9500-e44dcd30710a"
Just a suggestion - I'm often caught out with taxon names stored as
factor
, e.g. when I forget to setstringsAsFactors=FALSE
when reading in data, or if passing in results oftaxize::gbif_parse
.Of course a sensible solution is to remember to set
stringsAsFactors=FALSE
, and to suggest thatgbif_parse
returns acharacter
vector for itsscientificname
element.However, I wonder if it would be worth coercing factors to character within
search_names
as well?