ci_query error 'list cannot be coerced to double'
Hlynur-taekjavordur opened this issue · 5 comments
example query from webchem manual
y1 <- ci_query(c('Formaldehyde', 'Triclosan'), from = 'name')
Query is successful (HTTP 200), but returns the following error:
Error in FUN(X[[i]], ...) :
'list' object cannot be coerced to type 'double'
Hi All, I've looked into the code, ci_query()
should only work with CAS registry numbers ("rn"
) or InChI keys ("inchikey"
). The examples in the function's help page seem to work (although the match
argument is no longer used). Thanks @Hlynur-taekjavordur for raising this issue, can you please point me to this example in the webchem manual? I couldn't find it within the function description (https://docs.ropensci.org/webchem/reference/ci_query.html) or the vignette (https://cran.r-project.org/web/packages/webchem/vignettes/webchem.html). This seems to be an old example and should be removed I think.
example was from https://cran.r-project.org/web/packages/webchem/webchem.pdf page 12
I had been running ci_query successfully a few weeks ago, but then queries stopped working showing this error.
I can confirm now I can in some cases query cas numbers using rn and names successfully. All of the following queries are successful:
ci_query("D-Fructose-6-phosphate", c(from="name")
ci_query("D-Fructose-6-phosphate")
ci_query('26177-86-6', from = 'rn', match = 'first')
However, for some CAS numbers or names I get no results. For example querying for methanol (cas number 67-56-1 according to sigmaaldrich.com)
- query by name returns:
> ci_query('Methanol', from="name")
Querying Methanol. OK (HTTP 200).
More then one Link found. Multiple found. Returning first.
Querying 60-12-8. OK (HTTP 200).
Error in FUN(X[[i]], ...) :
'list' object cannot be coerced to type 'double'
- query by name match = "best" returns a result though not the expected one. Match ="ask" or "first" result in error
> ci_query('Methanol', from="name", match="best")
- query by cas (rn) returns error
> ci_query('67-56-1', from = 'rn', match = "first")
Querying 67-56-1. OK (HTTP 200).
Error in FUN(X[[i]], ...) :
'list' object cannot be coerced to type 'double'
library(webchem)
#examples from ?ci_query()
y1 <- ci_query('50-00-0', from = 'rn', match = 'first')
#> Error in ci_query("50-00-0", from = "rn", match = "first"): unused argument (match = "first")
y2 <- ci_query('WSFSSNUMVMOOMR-UHFFFAOYSA-N', from = 'inchikey')
#> Error in FUN(X[[i]], ...): 'list' object cannot be coerced to type 'double'
comps <- c("50-00-0", "64-17-5")
y3 <- ci_query(comps, from = "rn")
#> Error in FUN(X[[i]], ...): 'list' object cannot be coerced to type 'double'
Created on 2021-11-08 by the reprex package (v2.0.1)
This can be closed now that ci_query()
no longer can query by name. The reprex above no longer fails.