Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

Error in altmetrics: No metrics found for object #24

Open
gorkang opened this issue May 8, 2018 · 2 comments
Open

Error in altmetrics: No metrics found for object #24

gorkang opened this issue May 8, 2018 · 2 comments

Comments

@gorkang
Copy link

gorkang commented May 8, 2018

Right now, if you search for a DOI that does not have altmetric data, you get an error "No metrics found for object". Would it be possible for the function to just send a warning when the DOI is not found?

For example, if you do:

altmetrics(doi = "10.22199/s07187475.2015.0001.00004")

You will get:

Error in altmetrics(doi = "10.22199/s07187475.2015.0001.00004") : No metrics found for object

The main issue is that if I want to get the altmetric data for a group of papers, I have to include ways to keep on going when there is an error, so, something like this fails miserably:

DOIS = c("10.22199/s07187475.2015.0001.00004", "10.1093/brain/aww231", "10.1038/s41562-017-0118")
altmetrics_lists = DOIS %>% map( ~ altmetrics(doi = .x))
altmetrics_df = altmetrics_lists %>% map_df(~rAltmetric::altmetric_data(.x))

If I remove the offending DOI, I can get all the altmetric info easily:

DOIS = c("10.1093/brain/aww231", "10.1038/s41562-017-0118")
altmetrics_lists = DOIS %>% map( ~ altmetrics(doi = .x))
altmetrics_df = altmetrics_lists %>% map_df(~rAltmetric::altmetric_data(.x))

As far as I can see, changing: error("No metrics found for object") for warning("No metrics found for object") would suffice?

@gorkang
Copy link
Author

gorkang commented May 8, 2018

Just to be sure, I can do what I need with the following code, but it seems a bit too complex:

DOIS = c("10.22199/s07187475.2015.0001.00004", "10.1093/brain/aww231", "10.1038/s41562-017-0118")
altmetrics_lists = DOIS %>% map( ~ tryCatch( {altmetrics(doi = .x)},
                                             error = function(e) {
                                             cat(paste0("•Error• ", .x, "\n"))
                                             }))

altmetrics_lists[sapply(altmetrics_lists, is.null)] <- NULL
altmetrics_df = altmetrics_lists %>% map_df(~rAltmetric::altmetric_data(.x))

@karthik
Copy link
Member

karthik commented May 8, 2018

👋 @gorkang
Thanks for this report. I will change the behavior in an upcoming update. In the meantime, it is fairly simple to catch errors and skip them with some tidyverse code. See an example I wrote for another user yesterday:

https://gist.github.com/karthik/78016fc78d52156561f5f543defb7ec0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants