- Notifications
You must be signed in to change notification settings - Fork22
Open
Description
Could cr_abstract accept multiple DOI - like most functions in the package?
If not, a clearer error message would help:
library(rcrossref)cr_abstract(cr_r(2))#> Error in exists(z, private$crul_h_pool): first argument has length > 1
With some digging, I realised that I can already usecr_works for that, which is much faster than looping over cr_abstract. Is there an advantage to the current cr_abstract implementation? Or could it just be a wrapper for cr_works?
library(rcrossref)#Using cr_abstractmany_abstracts1<-function(dois) { lapply(dois,function(doi) {res<- try(cr_abstract(doi),silent=TRUE)if (inherits(res,"try-error")) {return(NA_character_) }else {return(res) } })}#Using cr_worksmany_abstracts2<-function(dois) {filt<-stats::setNames(dois, rep("doi", length(dois)))res<-rcrossref::cr_works(filter=filt,select= c("DOI","abstract"),limit= length(dois) )res$data$abstract }my_dois<- cr_r(100)system.time(abs1<- many_abstracts1(my_dois))#> user system elapsed#> 0.411 0.076 13.175sum(is.na(abs1))#> [1] 75system.time(abs2<- many_abstracts2(my_dois))#> user system elapsed#> 0.050 0.000 0.191sum(is.na(abs2))#> [1] 74
Created on 2025-10-02 withreprex v2.1.1
Metadata
Metadata
Assignees
Labels
No labels