Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s2_papers fails when papers have inconsistent type for year #5

Open
rdmorin opened this issue Oct 10, 2023 · 1 comment
Open

s2_papers fails when papers have inconsistent type for year #5

rdmorin opened this issue Oct 10, 2023 · 1 comment

Comments

@rdmorin
Copy link

rdmorin commented Oct 10, 2023

incompatible_papers = s2_papers(c("a661420975b9201e5f67b4c24527376f0a646a87", "3a5b354d117eeb86b62c8fc91296ce55464e9e71"))
Error in `dplyr::bind_rows()`:
! Can't combine `..1$year` <character> and `..2$year` <integer>.
Run `rlang::last_trace()` to see where the error occurred.

Looks like the year class for the second paper is 'character' but it's numeric for most papers. Is this a known issue? Maybe it only affects certain (newer) versions of dplyr?

packageVersion("dplyr")
[1] ‘1.1.2’
@rdmorin
Copy link
Author

rdmorin commented Oct 10, 2023

Looks like an easy fix. I modified one line in this function to force the year to be cast as numeric.

parse_s2_paper_md <- function(out) {
  out <- purrr::map_if(out, is.null, ~ NA_character_)
  tibble::tibble(
    abstract = out[["abstract"]],
    arxiv_id = out[["arxivId"]],
    authors = list(parse_s2_authors(out[["authors"]])),
    citation_velocity = out[["citationVelocity"]],
    citations = list(parse_s2_citations(out, "citations")),
    doi = out[["doi"]],
    influential_citation_count = out[["influentialCitationCount"]],
    paper_id = out[["paperId"]],
    references = list(parse_s2_citations(out, "references")),
    title = out[["title"]],
    topics = list(parse_s2_topics(out[["topics"]])),
    url = out[["url"]],
    venue = out[["venue"]],
    year = as.numeric(out[["year"]])
  )
}

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

No branches or pull requests

1 participant