Closed OAIWetz closed 1 year ago
Thank you for reporting @OAIWetz. Could you give me a reproducible example (a small snippet of code) that is giving you issues? Or a work id that you're having problems with? I'm not sure if the error is in oa2bibliometrix
or oa2df
...
My code is the following Coming from openalex API call
(1)
cau_deep_oa <- openalexR::oa_query(entity = "works", authorships.institutions.id = "I32021983", locations.source.publisher_lineage = "(P4310310987 OR P4310320527 OR P4310320503 OR P4310319945 OR P4310320017 OR P4310320083 OR P4310317820 OR P4310313990 OR P4310319871", endpoint = "https://api.openalex.org", identifier = NULL)
(2)
cau_deep_oa_data <- openalexR::oa_request(query_url = cau_deep_oa, count_only = FALSE,verbose = TRUE)
(3)
cau_deep_oa_data_df <- openalexR::oa2df(data = cau_deep_oa_data, entity = "works", verbose = TRUE) converting [===============================] 100% eta: 0s
(4)
cau_deep_oa_bibmet <- openalexR::oa2bibliometrix(cau_deep_oa_data_df)
Error in openalexR::oa2bibliometrix(cau_deep_oa_data_df) : object 'countrycode' not found In addition: Warning message: In utils::data("countrycode", envir = environment()) : data set ‘countrycode’ not found
Best regards
Oh I see. countrycode
is a dataset exported by openalexR, so you would need to call library(openalexR)
in your code. I will find a way to fix this so you don't need to do this, but in the mean time, this is a good workaround.
Another note I want to add: in OpenAlex queries, the OR operator is denoted as |
, which is already implemented in the package for you. So all you need to supply to the argument is the vector.
So, to simplify your code above:
library(openalexR)
lineages <- c("P4310310987", "P4310320527", "P4310320503", "P4310319945", "P4310320017", "P4310320083", "P4310317820", "P4310313990", "P4310319871")
cau_deep_oa_data_df <- oa_fetch(
entity = "works",
authorships.institutions.id = "I32021983",
locations.source.publisher_lineage = lineages,
verbose = TRUE
)
#> Requesting url: https://api.openalex.org/works?filter=authorships.institutions.id%3AI32021983%2Clocations.source.publisher_lineage%3AP4310310987%7CP4310320527%7CP4310320503%7CP4310319945%7CP4310320017%7CP4310320083%7CP4310317820%7CP4310313990%7CP4310319871
#> Getting 39 pages of results with a total of 7646 records...
cau_deep_oa_bibmet <- oa2bibliometrix(cau_deep_oa_data_df)
Created on 2023-07-04 with reprex v2.0.2
Resolved in #121. Now you can do:
lineages <- c("P4310320017", "P4310320083", "P4310317820")
cau_deep_oa_data_df <- openalexR::oa_fetch(
entity = "works",
authorships.institutions.id = "I32021983",
locations.source.publisher_lineage = lineages,
verbose = TRUE
)
#> Requesting url: https://api.openalex.org/works?filter=authorships.institutions.id%3AI3...
#> Getting 7 pages of results with a total of 1233 records...
cau_deep_oa_bibmet <- openalexR::oa2bibliometrix(cau_deep_oa_data_df)
Created on 2023-07-20 with reprex v2.0.2
Hello everyone,
it seems that there may be an issue with openalexR::oa2bibliometrix: See Manual p. 7 https://cran.r-project.org/web/packages/openalexR/openalexR.pdf
It keeps telling: "Error in openalexR::oa2bibliometrix(df = x) : object 'countrycode' not found In addition: Warning message: In utils::data("countrycode", envir = environment()) : data set ‘countrycode’ not found
When I do variable2 <- openalexR::oa2df(entity = "works", data = (variable1)), it works fine. Then I define a column and values with mutate() in dplyr according to country_code specs and still openalexR::oa2bibliometrix issues a warning and doesn't convert. I could not coerce either.
Working with tidyjson() in a previous step didn't help me as country_code Elements are available from the downloaded data sets.
Could anyone help, please?
Thank you in advance