Skip to content

Problem with function iucn_summary() of taxize package, returning error in strsplit()

3 messages · Augusto Ribas, Sarah Goslee, Eduard Szöcs

#
Hello

I'm using the package taxize and was trying to use the function
iucn_summary() but it work perfectly  with the examples, but when i
try another name i receive the error msg:

#####
Erro em strsplit(pop, split = ":") : argumento modo n?o caractere
######

My r is in Portuguese, but it say argument mode not a character.

I checked this specie on iucn site and its there, dunno what is the problem.


the examples i cite are:

#
library(taxize)

iucn_summary("Lynx lynx")

iucn_summary("aaaa")

iucn_summary("Molossus currentium")
#

first two work properly, but the third give an error.. i have no idea
of what i'm doing wrong.

I'm using ubunto here, with R 2.15.2 from emacs.

Thanks for the attention.
#
Hi Augusto,

I took a quick look at the code for iucn_summary, and it looks like a bug to me.

I copied the package maintainer on this reply, as is appropriate for
problems with a particular package.

It looks like:
pop <- xpathSApply(h, "//div[@id=\"population\"]/text()[preceding-sibling::br]",
                xmlValue)

is returning an empty list, which then throws an error in the next line:
pop <- do.call(rbind, lapply(strsplit(pop, split = ":"),
                rbind))


It looks like the function works well for complete cases, but has
problems with certain missing/different data (easy mistake I've
committed myself a time or two). You've hit on one of those fringe
cases by accident, and it should be an easy update to the package.

Sarah
On Wed, Dec 19, 2012 at 2:15 PM, Augusto Ribas <ribas.aca at gmail.com> wrote:
--
Sarah Goslee
http://www.functionaldiversity.org
#
Hai Augusto,

thanks for reporting this bug!

I just pushed a fixed version, where NA is returned when the IUCN-API 
does not return anything.
You can install the newest version from github via:

install.packages("devtools")
require(devtools)
install_github("taxize_",  "ropensci")
require(taxize)


Happy holidays,

Eduard
On 12/19/2012 08:29 PM, Sarah Goslee wrote: