ropensci/europepmc

Error in epmc_annotations_by_id() when article has pubmed ID, but lacks PMCID (europepmc 0.4.1)

Closed this issue · 2 comments

First of all, thank you for your work.
Using europepmc I found out that there are articles, which lack PMCID and still have some annotations though.
Unfortunately, it is impossible to retrive them because (europepmc 0.4.1):

epmc_annotations_by_id("MED:10566658")
No encoding supplied: defaulting to UTF-8.
Ошибка: Internal error in df_slice(): Columns must match the data frame size.
Run rlang::last_error() to see where the error occurred.
> rlang::last_error()
<error/rlang_error>
Internal error in df_slice(): Columns must match the data frame size.
Backtrace:
1. europepmc::epmc_annotations_by_id("MED:10566658")
2. purrr::map_df(ids, epmc_annotations_by_id_, .pb = pb)
3. purrr::map(.x, .f, ...)
4. europepmc:::.f(.x[[i]], ...)
7. tidyr:::unnest.data.frame(out, .data$annotations)
8. tidyr::unchop(data, any_of(cols), keep_empty = keep_empty, ptype = ptype)
9. vctrs::vec_slice(data, slice_loc)
Run rlang::last_trace() to see the full context.

I guess that the problem is in annotations_by_id.R, epmc_annotations_by_id_, line 63:
pmcid = req[["pmcid"]],
I think it could be changed to
pmcid = if_else(is.null(req[["pmcid"]]), NA_character_, req[["pmcid"]]),

Regards.

Thank you for your report. I implemented your fix and it works as expected 🎉 Please re-install the dev version from GitHub.

Sorry for the late reply and thank you, dev-version is installed and there is no issue with the articles lacking PMCID.