ropensci / openalexR

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

Raw affiliation string #245

Closed DAAVLIB closed 5 months ago

DAAVLIB commented 5 months ago

Hello there, First of all, I'd like to thank you for this great package - it's proven to be very helpful and I appreciate it a great deal!

I'm wondering if there's a bug in the way the package is grabbing/storing the raw affiliation string. When I run the code and unnest the author field, the raw affiliation gets populated over multiple fields. I ran this code and the result can be seen below:

library(openalexR)
library(tidyverse)

test_works <- oa_fetch( entity = "works", identifier = c("W1964141474"), verbose = TRUE )

test_authors <- test_works %>% unnest(author)

image

In this example, there are only 3 fields that are created but with multiple authors and/or multiple affiliations, the field range can increase quite dramatically. I took a look at the JSON output for this particular work and I can't seem to see a problem on the OA end so I'm wondering if it's something to do with the package update? It used to work well before where the raw affiliation string was kept in one discrete field.

Thank you for looking into this and thanks again for the great package!

Mario

trangdata commented 5 months ago

@DAAVLIB Thank you for reporting this issue. This is a duplicate of #240 and has been fixed in #241. Could you install the github version of the package and try again? 🙏🏽

# remotes::install_github("ropensci/openalexR")
openalexR::oa_fetch(
  identifier = "W1964141474",
  verbose = TRUE
) |>
  tidyr::unnest(author) |> 
  dplyr::select(au_affiliation_raw)
#> Requesting url: https://api.openalex.org/works/W1964141474
#> # A tibble: 3 × 1
#>   au_affiliation_raw                                                            
#>   <chr>                                                                         
#> 1 McGovern Institute for Brain Research, Department of Brain and Cognitive Scie…
#> 2 McGovern Institute for Brain Research, Department of Brain and Cognitive Scie…
#> 3 Institute for Medical Engineering & Science, Cambridge, MA 02139, United Stat…

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

DAAVLIB commented 5 months ago

Thank you so much for your prompt and efficient response! And apologies for bringing up a bug that was already fixed.

Have a great day!