ropensci / openalexR

Getting bibliographic records from OpenAlex
https://docs.ropensci.org/openalexR/
Other
91 stars 20 forks source link

Lexical and functional errors in filters #122

Closed Quadrophonia closed 1 year ago

Quadrophonia commented 1 year ago

First, thanks for producing this library! I'm trying to find all papers that cite a particular paper, and that also feature particular words in the title. However, when I run my code, I get errors that I can't explain. For example, I try:

> works_search <- oa_fetch(
+   entity = "works",
+   abstract.search = c("neurology", "the office", "tap water"),
+   from_publication_date = "2018-01-01",
+   to_publication_date = "2023-04-30"
+ )
Error: lexical error: invalid char in json text.
                                       There was an error processing y
                     (right here) ------^
> 

I don't think this lexical error arises from too large an intersection, because the following code also produces a different error:

> works_search <- oa_fetch(
+   entity = "works",
+   abstract.search = c("dddghfgh", "dfgh"),
+   from_publication_date = "2018-01-01",
+   to_publication_date = "2023-04-30"
+ )
Error in (function (..., deparse.level = 1, make.row.names = TRUE, stringsAsFactors = FALSE,  : 
  numbers of columns of arguments do not match
> 

The full code produces the same error as above:

> works_search <- oa_fetch(
+   entity = "works",
+   cites = "W2741809807",
+   abstract.search = c("neurology", "the office", "tap water"),
+   from_publication_date = "2018-01-01",
+   to_publication_date = "2023-04-30"
+ )
Error in (function (..., deparse.level = 1, make.row.names = TRUE, stringsAsFactors = FALSE,  : 
  numbers of columns of arguments do not match
>

I have read through the openalexR and OpenAlex API documentation but I can't seem to find a solution or a clue to my problem. I bet it is a simple error. I am running:

Any help would be warmly appreciated! Thanks!

trangdata commented 1 year ago

Hi @Quadrophonia thanks so much for using openalexR! 🌱

I think this issue has recently been fixed but the new version is not yet released. Could you try downloading the package from GitHub and try again?

install.packages("remotes")
remotes::install_github("ropensci/openalexR")
library(openalexR)
#> Thank you for using openalexR!
#> To acknowledge our work, please cite the package by calling
#> `citation("openalexR")`.
works_search <- oa_fetch(
  entity = "works",
  cites = "W2741809807",
  abstract.search = c("neurology", "the office", "tap water"),
  from_publication_date = "2018-01-01",
  to_publication_date = "2023-04-30"
)
works_search
#> # A tibble: 4 × 31
#>   id       displ…¹ author ab    publi…² relev…³ so    so_id host_…⁴ issn_l url  
#>   <chr>    <chr>   <list> <chr> <chr>     <dbl> <chr> <chr> <chr>   <chr>  <chr>
#> 1 https:/… The NI… <df>   Cita… 2019-1…    129. PLOS… http… Public… 1544-… http…
#> 2 https:/… Benefi… <lgl>  Tabl… 2020-0…     NA  Amer… http… <NA>    <NA>   http…
#> 3 https:/… Taking… <df>   Acce… 2022-0…     NA  Limn… http… Wiley   2378-… http…
#> 4 https:/… Medica… <df>   Medi… 2022-1…     NA  Cure… http… Cureus… 2168-… http…
#> # … with 20 more variables: pdf_url <chr>, license <chr>, version <chr>,
#> #   first_page <chr>, last_page <chr>, volume <chr>, issue <chr>, is_oa <lgl>,
#> #   cited_by_count <int>, counts_by_year <list>, publication_year <int>,
#> #   cited_by_api_url <chr>, ids <list>, doi <chr>, type <chr>,
#> #   referenced_works <list>, related_works <list>, is_paratext <lgl>,
#> #   is_retracted <lgl>, concepts <list>, and abbreviated variable names
#> #   ¹​display_name, ²​publication_date, ³​relevance_score, ⁴​host_organization

Created on 2023-07-14 with reprex v2.0.2

Quadrophonia commented 1 year ago

Thanks so much, @trangdata - those errors now appear solved!

rkrug commented 1 year ago

Cautiously optimistic - it ran with a subset it did not run before. I will now start the run with all works.