ropensci / openalexR

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

Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, : arguments imply differing number of rows: 1, 0 #236

Closed jwbesse closed 4 months ago

jwbesse commented 5 months ago

Dear openalexR team,

I'm running the following code to get papers matching certain search strings:

works_title <- oa_fetch(
  entity = "works",
  per_page = 200, 
  paging = "cursor", 
  title.search = c("Neurotechnology", 
                   "Neuroinformatics"),

  from_publication_date = "2021-01-01",
  to_publication_date = "2023-12-31",

  cited_by_count = ">1",
  options = list(sort = "cited_by_count:desc"),
  verbose = TRUE
)

However, I'm getting the following error:


Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,  : 
  arguments imply differing number of rows: 1, 0

Is there anything you can tell me which might help solve the issue?

DrMattG commented 5 months ago

I was hitting the same problem. I updated to the github version of the package and that solved the issue for me.

remotes::install_github("ropensci/openalexR")

Using your example:

library(openalexR)
#> Thank you for using openalexR!
#> To acknowledge our work, please cite the package by calling `citation("openalexR")`.
#> To suppress this message, add `openalexR.message = suppressed` to your .Renviron file.
works_title <- oa_fetch(
  entity = "works",
  per_page = 200, 
  paging = "cursor", 
  title.search = c("Neurotechnology", 
                   "Neuroinformatics"),

  from_publication_date = "2021-01-01",
  to_publication_date = "2023-12-31",

  cited_by_count = ">1",
  options = list(sort = "cited_by_count:desc"),
  verbose = TRUE
)
#> Requesting url: https://api.openalex.org/works?filter=title.search%3ANeurotechnology%7CNeuroinformatics%2Cfrom_publication_date%3A2021-01-01%2Cto_publication_date%3A2023-12-31%2Ccited_by_count%3A%3E1&sort=cited_by_count%3Adesc
#> Getting 1 page of results with a total of 82 records...

works_title |> head()
#> # A tibble: 6 × 38
#>   id                title display_name author ab    publication_date so    so_id
#>   <chr>             <chr> <chr>        <list> <chr> <chr>            <chr> <chr>
#> 1 https://openalex… Reco… Recommendat… <df>   "Adv… 2021-04-29       Neur… http…
#> 2 https://openalex… MEMS… MEMS induct… <df>   "MEM… 2021-08-11       Micr… http…
#> 3 https://openalex… A St… A Standards… <df>   "The… 2021-01-27       Neur… http…
#> 4 https://openalex… Tran… Transient e… <df>   "Neu… 2021-12-01       Curr… http…
#> 5 https://openalex… Mobi… Mobilizing … <df>    <NA> 2021-06-01       Natu… http…
#> 6 https://openalex… Inte… Integrative… <df>   "Des… 2021-09-07       Fron… http…
#> # ℹ 30 more variables: host_organization <chr>, issn_l <chr>, url <chr>,
#> #   pdf_url <chr>, license <chr>, version <chr>, first_page <chr>,
#> #   last_page <chr>, volume <chr>, issue <chr>, is_oa <lgl>,
#> #   is_oa_anywhere <lgl>, oa_status <chr>, oa_url <chr>,
#> #   any_repository_has_fulltext <lgl>, language <chr>, grants <list>,
#> #   cited_by_count <int>, counts_by_year <list>, publication_year <int>,
#> #   cited_by_api_url <chr>, ids <list>, doi <chr>, type <chr>, …

Created on 2024-04-29 with reprex v2.0.2 `

trangdata commented 5 months ago

Thank you @DrMattG! 🙏🏽 I got the same result!

@jwbesse I believe this is now fixed with #233. Please let me know if you still encounter the error after installing the github version of the package.

remotes::install_github("ropensci/openalexR")
Scientometrics101 commented 5 months ago

Hello, I am encountering this same original problem and I have tried the above proposed solution of installing the github version of the package.

trangdata commented 5 months ago

@Scientometrics101 Could you let us know which version of the package you're using?

library(openalexR)
packageVersion("openalexR")
#> [1] '1.2.2.9999'
works_title <- oa_fetch(
  entity = "works",
  title.search = "Neurotechnology",
  publication_date = "2021-01-01",
  verbose = TRUE
)
#> Requesting url: https://api.openalex.org/works?filter=title.search%3ANeurotechnology%2Cpublication_date%3A2021-01-01
#> Getting 1 page of results with a total of 34 records...
works_title
#> # A tibble: 34 × 39
#>    id     title display_name author ab    publication_date relevance_score so   
#>    <chr>  <chr> <chr>        <list> <chr> <chr>                      <dbl> <chr>
#>  1 https… Neur… Neurotechno… <df>   Neur… 2021-01-01                 175.  Vest…
#>  2 https… Stan… Standardiza… <df>   Edit… 2021-01-01                 131.  IEEE…
#>  3 https… Clin… Clinical Ne… <df>   <NA>  2021-01-01                 120.  Adva…
#>  4 https… The … The Securit… <df>   This… 2021-01-01                 112.  Adva…
#>  5 https… Intr… Introductio… <df>   In t… 2021-01-01                 108.  Adva…
#>  6 https… NEUR… NEUROTECHNO… <df>   The … 2021-01-01                 105.  Peda…
#>  7 https… Perc… Perception … <df>   Abst… 2021-01-01                 104.  Leon…
#>  8 https… Can … Can BCIs En… <df>   Pass… 2021-01-01                  97.3 Adva…
#>  9 https… Bioc… Bioculture … <df>   This… 2021-01-01                  94.7 Deve…
#> 10 https… Brai… Brain-Compu… <df>   Impo… 2021-01-01                  87.4 Adva…
#> # ℹ 24 more rows
#> # ℹ 31 more variables: so_id <chr>, host_organization <chr>, issn_l <chr>,
#> #   url <chr>, pdf_url <chr>, license <chr>, version <chr>, first_page <chr>,
#> #   last_page <chr>, volume <chr>, issue <chr>, is_oa <lgl>,
#> #   is_oa_anywhere <lgl>, oa_status <chr>, oa_url <chr>,
#> #   any_repository_has_fulltext <lgl>, language <chr>, grants <list>,
#> #   cited_by_count <int>, counts_by_year <list>, publication_year <int>, …

Created on 2024-05-02 with reprex v2.0.2

andreaspacher commented 4 months ago

I have the same problem with the package version 1.2.3.

it would be great to see a solution, thanks for your efforts!

trangdata commented 4 months ago

@andreaspacher I'm sorry that you're still getting an error. Could you try re-installing one more time? v1.3.0 should work now.

remotes::install_github("ropensci/openalexR")
packageVersion("openalexR")
#> [1] '1.3.0'

Created on 2024-05-07 with reprex v2.0.2