Skip to content

Commit

Permalink
Merge pull request #269 from ropensci/fix-empty-refs
Browse files Browse the repository at this point in the history
Handles NULL edges in oa_snowball
  • Loading branch information
trangdata authored Sep 9, 2024
2 parents 6f0fc45 + 207bf62 commit 0bc9a7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions R/oa_snowball.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ oa_snowball <- function(identifier = NULL,

# relationships/edges
edges <- rbind(citing_rel, cited_rel)
if (is.null(edges)) {
message("No citations and no references for ", identifier)
edges <- tibble::tibble(from = character(0), to = character(0))
return(list(nodes = nodes, edges = edges))
}
# remove duplicates when two input identifiers cite each other
edges <- edges[!duplicated(edges), ]
# remove edges to/from NA nodes
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-oa_snowball.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test_that("oa_snowball works for recent articles with no citations yet", {

Sys.sleep(1/10)
snowball_docs <- oa_snowball(
identifier = c("W4295757800", "W4296128995", "W4297497355")
identifier = c("W2033458484")
)
expect_true(is.list(snowball_docs))
})
Expand Down

0 comments on commit 0bc9a7a

Please sign in to comment.