diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 40c75b8c..cfff312d 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -38,7 +38,7 @@ jobs: devtools::check(error_on = "warning") - name: Build Package Website run: | - muggle::build_site2() + muggle::build_site2(override = list(new_process = FALSE)) - name: Build Buildtime Image uses: docker/build-push-action@v1 with: diff --git a/NAMESPACE b/NAMESPACE index 8f075489..b939bc4d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -11,6 +11,7 @@ export(cr_compliance_overview) export(cr_funder_df) export(cr_has_orcid) export(cr_tdm_df) +export(doi_examples) export(draft_report) export(emailReport) export(emailReportServer) @@ -44,7 +45,6 @@ export(runMetacheck) export(smtp_send_mc) export(tabulate_metacheckable) export(tdm_metrics) -export(tu_dois) export(vor_issue) import(dplyr) import(purrr) diff --git a/R/communicate.R b/R/communicate.R index e42b483f..f56881b8 100644 --- a/R/communicate.R +++ b/R/communicate.R @@ -99,7 +99,7 @@ mcControlsServer <- function(id, translator = mc_translator()) { shiny::observe(shiny.i18n::update_lang(session, lang())) dois <- biblids::doiEntryServer( id = "dois", - example_dois = tu_dois()[1:30], + example_dois = doi_examples$good[1:30], char_limit = 50000L, translator = translator, lang = lang diff --git a/R/cr_md_funder.R b/R/cr_md_funder.R index cd557fb7..ddfb41af 100644 --- a/R/cr_md_funder.R +++ b/R/cr_md_funder.R @@ -32,4 +32,3 @@ empty_funder <- function(cr) { } out } - diff --git a/R/data.R b/R/data.R index 3bd8c3db..5136b123 100644 --- a/R/data.R +++ b/R/data.R @@ -1,31 +1,43 @@ -#' Some DOIs for testing -#' @keywords internal -#' @export -tu_dois <- function() { - readr::read_lines(file = system_file2("extdata", "dois", "tu.txt")) -} - -#' Long list of DOIs -#' @noRd -dois_many <- function() { - res <- readr::read_lines(file = system_file2("extdata", "dois", "many.txt")) - biblids::as_doi(res) -} +# ==== example dois -#' Some troublesome DOIs for testing -#' @noRd -dois_weird <- function() { - c( - # these are roughly in the order of metacheckable predicates - "10.1000/1", - NA, # there's no meaningful metadata for an NA DOI - "doi:10.1000/1", # duplicated from above - "10.3389/fbioe.2020.00209", # actually from CR - "10.1000/2", - "10.1000/3", # would exceed limit of 4 - # caused issues in https://github.com/subugoe/metacheck/issues/181 - "10.1007/s00330-019-06284-8", - # caused issues in https://github.com/subugoe/metacheck/issues/181 - "10.1007/s00431-018-3217-8" - ) -} +#' DOIs included in the package for testing and illustration +#' @format A list of [biblids::doi()] vectors, including: +#' - `good`: Guaranteed to work (all are [is_metacheckable()]). +#' - `many`: Long list of DOIs. +#' - `weird`: Troublesome DOIs. +#' - `biblids`: [biblids::doi_examples()] +#' +#' @examples +#' doi_examples$good +#' +#' @family data +#' @export +doi_examples <- list( + # these are originally from TU users + good = biblids::as_doi( + readr::read_lines( + file = system.file("extdata", "dois", "tu.txt", package = "metacheck")) + ), + many = biblids::as_doi( + readr::read_lines( + file = system.file("extdata", "dois", "many.txt", package = "metacheck") + ) + ), + weird = biblids::as_doi( + c( + # these are roughly in the order of metacheckable predicates + "10.1000/1", + NA, # there's no meaningful metadata for an NA DOI + "doi:10.1000/1", # duplicated from above + "10.3389/fbioe.2020.00209", # actually from CR + "10.1000/2", + "10.1000/3", # would exceed limit of 4 + # caused issues in https://github.com/subugoe/metacheck/issues/181 + "10.1007/s00330-019-06284-8", + # caused issues in https://github.com/subugoe/metacheck/issues/181 + "10.1007/s00431-018-3217-8", + "10.3389/fmech.2020.566440/full" # superfluous url fragment + ) + ), + biblids = biblids::doi_examples() +) diff --git a/R/email.R b/R/email.R index 889ff85d..4f9e51c1 100644 --- a/R/email.R +++ b/R/email.R @@ -119,7 +119,7 @@ block_text_centered_vec <- function(...) { #' @param session_id Character vector to identify current shiny session #' @inheritDotParams blastula::render_email #' @export -mc_render_email <- function(dois = tu_dois()[1:10], +mc_render_email <- function(dois = doi_examples$good[1:10], translator = mc_translator(), session_id = NULL, ...) { diff --git a/R/metacheck_package.R b/R/metacheck.R similarity index 100% rename from R/metacheck_package.R rename to R/metacheck.R diff --git a/R/metrics_cc.R b/R/metrics_cc.R index 0a0d74c6..659bcb11 100644 --- a/R/metrics_cc.R +++ b/R/metrics_cc.R @@ -1,28 +1,22 @@ -#' CC license variants metrics overview +#' Diagnose Creative Commons Licensing +#' @family transform +#' @examples +#' # obtain metadata from Crossref API +#' req <- get_cr_md(doi_examples$good) #' -#' Presents normalised CC licence variants like BY (absolute and relative) +#' # check article-level compliance +#' out <- cr_compliance_overview(req) +#' @name cc +NULL + +#' @describeIn cc Presents normalised CC licence variants. +#' For example, `BY` (absolute and relative). #' #' @param cc_license_check tibble, result from [license_check()] -#' #' @export -#' #' @examples -#' \dontrun{ -#' my_dois <- c("10.5194/wes-2019-70", "10.1038/s41598-020-57429-5", -#' "10.3389/fmech.2019.00073", "10.1038/s41598-020-62245-y", -#' "10.1109/JLT.2019.2961931") -#' -#' # Workflow: -#' # First, obtain metadata from Crossref API -#' req <- get_cr_md(my_dois) -#' -#' # Then, check article-level compliance -#' out <- cr_compliance_overview(req) -#' -#' # Obtain CC variants metrics +#' # obtain CC variants metrics #' cc_metrics(out$cc_license_check) -#' } -#' @keywords internal cc_metrics <- function(cc_license_check = NULL) { is_cr_license_df(cc_license_check) cc_license_check %>% @@ -30,25 +24,13 @@ cc_metrics <- function(cc_license_check = NULL) { dplyr::mutate(prop = .data$value / sum(.data$value) * 100) } -#' CC compliance metrics overview -#' -#' Presents the result of the CC compliance check (absolute and relative) +#' @describeIn cc Presents the result of the CC compliance check. +#' Absolute and relative normalised CC licence variants. #' #' @seealso [license_check()] -#' -#' @inheritParams cc_metrics -#' #' @export -#' #' @examples -#' # Workflow: -#' # First, obtain metadata from Crossref API -#' req <- get_cr_md(tu_dois()[7:10]) -#' -#' # Then, check article-level compliance -#' out <- cr_compliance_overview(req) -#' -#' # Obtain CC compliance check resutls metrics +#' # Obtain cc compliance check resutls metrics #' cc_compliance_metrics(out$cc_license_check) #' @keywords internal cc_compliance_metrics <- function(cc_license_check = NULL) { diff --git a/R/metrics_funder.R b/R/metrics_funder.R index 82390a81..88393f51 100644 --- a/R/metrics_funder.R +++ b/R/metrics_funder.R @@ -10,22 +10,15 @@ #' @param funder_info tibble obtained with [cr_funder_df()] or [cr_compliance_overview()] #' @export #' -#' @examples \dontrun{ -#' ## Some DOIs from OA articles -#' my_dois <- c("10.5194/wes-2019-70", "10.1038/s41598-020-57429-5", -#' "10.3389/fmech.2019.00073", "10.1038/s41598-020-62245-y", -#' "10.1109/JLT.2019.2961931") -#' -#' # Workflow: +#' @examples #' # First, obtain metadata from Crossref API -#' req <- get_cr_md(my_dois) +#' req <- get_cr_md(doi_examples$good) #' #' # Then, check article-level compliance -# out <- cr_compliance_overview(req) +#' out <- cr_compliance_overview(req) #' #' # Obtain funder metrics overview #' funder_metrics(out$funder_info) -#' } #' @keywords internal funder_metrics <- function(funder_info = NULL) { is_cr_funder_df(funder_info) diff --git a/R/metrics_overview.R b/R/metrics_overview.R index 0d3a0cb5..c386ce93 100644 --- a/R/metrics_overview.R +++ b/R/metrics_overview.R @@ -18,22 +18,15 @@ #' #' @export #' -#' @examples \dontrun{ -#' ## Some DOIs from OA articles -#' my_dois <- c("10.5194/wes-2019-70", "10.1038/s41598-020-57429-5", -#' "10.3389/fmech.2019.00073", "10.1038/s41598-020-62245-y", -#' "10.1109/JLT.2019.2961931") -#' -#' # Workflow: +#' @examples #' # First, obtain metadata from Crossref API -#' req <- get_cr_md(my_dois) +#' req <- get_cr_md(doi_examples$good) #' #' # Then, check article-level compliance -# out <- cr_compliance_overview(my_dois) +#' out <- cr_compliance_overview(req) #' #' # Finally, obtain compliance metrics overview -#' metrics_overview(out) -#' } +#' metrics_overview(out$cr_overview) #' @keywords internal metrics_overview <- function(cr_overview = NULL) { is_cr_overview_df(cr_overview) diff --git a/R/metrics_tdm.R b/R/metrics_tdm.R index f6a505dc..f0b29c5e 100644 --- a/R/metrics_tdm.R +++ b/R/metrics_tdm.R @@ -12,22 +12,15 @@ #' @param tdm tibble obtained with [cr_tdm_df()] or [cr_compliance_overview()] #' @export #' -#' @examples \dontrun{ -#' ## Some DOIs from OA articles -#' my_dois <- c("10.5194/wes-2019-70", "10.1038/s41598-020-57429-5", -#' "10.3389/fmech.2019.00073", "10.1038/s41598-020-62245-y", -#' "10.1109/JLT.2019.2961931") -#' -#' # Workflow: +#' @examples #' # First, obtain metadata from Crossref API -#' req <- get_cr_md(my_dois) +#' req <- get_cr_md(doi_examples$good) #' #' # Then, check article-level compliance -# out <- cr_compliance_overview(req) +#' out <- cr_compliance_overview(req) #' #' # Finally, obtain TDM metrics overview #' tdm_metrics(out$tdm) -#' } #' @keywords internal tdm_metrics <- function(tdm = NULL) { is_cr_tdm_df(tdm) diff --git a/R/report.R b/R/report.R index b6296523..b7e3f277 100644 --- a/R/report.R +++ b/R/report.R @@ -41,7 +41,9 @@ draft_report <- function(lang = mc_langs, ...) { #' @inheritDotParams rmarkdown::render #' @inheritParams mcControlsServer #' @export -render_report <- function(dois = tu_dois(), translator = mc_translator(), ...) { +render_report <- function(dois = doi_examples$good, + translator = mc_translator(), + ...) { stopifnot(!shiny::is.reactive(dois)) checkmate::assert_vector(dois, min.len = 1, null.ok = FALSE) dois <- biblids::as_doi(dois) @@ -58,7 +60,7 @@ render_report <- function(dois = tu_dois(), translator = mc_translator(), ...) { #' @noRd knit_child_report <- function(...) { # knit_child does not know params, so these have to be in env - params <<- list(dois = tu_dois()) + params <<- list(dois = doi_examples$good) res <- knitr::knit_child( path_report_rmd(...), quiet = TRUE diff --git a/inst/extdata/dois/many.txt b/inst/extdata/dois/many.txt index 68ab9dea..3f1f7b9d 100644 --- a/inst/extdata/dois/many.txt +++ b/inst/extdata/dois/many.txt @@ -1583,4 +1583,6 @@ 10.2478/s11756-020-00474-2 10.2478/s11756-020-00475-1 10.3758/s13415-018-00647-2 -10.4153/cjm-2017-045-0 \ No newline at end of file +10.4153/cjm-2017-045-0 +10.5194/wes-5-1375-2020 +10.5194/wes-5-721-2020 diff --git a/inst/extdata/dois/tu.txt b/inst/extdata/dois/tu.txt index 68f8453c..75512a40 100644 --- a/inst/extdata/dois/tu.txt +++ b/inst/extdata/dois/tu.txt @@ -1,4 +1,3 @@ -10.5194/wes-2019-70 10.1038/s41598-020-57429-5 10.3389/fmech.2019.00073 10.1038/s41598-020-62245-y @@ -51,9 +50,7 @@ 10.3389/fmech.2020.00039 10.3389/fmicb.2020.01284 10.1016/j.envint.2020.105867 -10.5194/wes-5-819-202 10.1016/j.egyr.2020.06.028 -10.5194/wes-5-721-2020 10.1186/s12939-020-01191-7 10.3390/en13081993 10.3390/su12083394 @@ -81,7 +78,6 @@ 10.3389/fmech.2020.00057 10.1088/1748-9326/aba2fe 10.5194/hess-24-3835-2020 -10.1039/D0RA05997H 10.3389/fbioe.2020.00854 10.3389/fnins.2020.00795 10.3389/fmech.2020.00069 @@ -120,12 +116,10 @@ 10.3390/recycling5030019 10.3390/mi11090866 10.3390/en13205348 -10.3389/fmech.2020.566440/full 10.1088/1748-9326/abbd63 10.3390/su12197984 10.5194/gmd-13-4435-2020 10.36900/suburban.v8i3.523 -10.5194/wes-5-1375-2020 10.1002/ejlt.202000213 10.1002/cbic.202000257 10.1002/adfm.202007294 diff --git a/inst/rmarkdown/templates/bericht/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/bericht/skeleton/skeleton.Rmd index eb0d7945..4d04e340 100644 --- a/inst/rmarkdown/templates/bericht/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/bericht/skeleton/skeleton.Rmd @@ -2,7 +2,7 @@ output: blastula::blastula_email title: "Metacheck Bericht" params: - dois: !r metacheck:::tu_dois() + dois: !r metacheck::doi_examples$good translator: !r metacheck::mc_translator() session_id: NULL --- diff --git a/inst/rmarkdown/templates/report/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/report/skeleton/skeleton.Rmd index c9326cc7..23a09184 100644 --- a/inst/rmarkdown/templates/report/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/report/skeleton/skeleton.Rmd @@ -2,7 +2,7 @@ output: blastula::blastula_email title: "Metacheck Report" params: - dois: !r metacheck:::tu_dois() + dois: !r metacheck::doi_examples$good translator: !r metacheck::mc_translator() session_id: NULL --- diff --git a/man/cc.Rd b/man/cc.Rd new file mode 100644 index 00000000..7e032199 --- /dev/null +++ b/man/cc.Rd @@ -0,0 +1,54 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/metrics_cc.R +\name{cc} +\alias{cc} +\alias{cc_metrics} +\alias{cc_compliance_metrics} +\title{Diagnose Creative Commons Licensing} +\usage{ +cc_metrics(cc_license_check = NULL) + +cc_compliance_metrics(cc_license_check = NULL) +} +\arguments{ +\item{cc_license_check}{tibble, result from \code{\link[=license_check]{license_check()}}} +} +\description{ +Diagnose Creative Commons Licensing +} +\section{Related Functions and Methods}{ +\subsection{Functions}{ +\itemize{ +\item \code{cc_metrics}: Presents normalised CC licence variants. +For example, \code{BY} (absolute and relative). +} +\itemize{ +\item \code{cc_compliance_metrics}: Presents the result of the CC compliance check. +Absolute and relative normalised CC licence variants. +}}} + +\examples{ +# obtain metadata from Crossref API +req <- get_cr_md(doi_examples$good) + +# check article-level compliance +out <- cr_compliance_overview(req) +# obtain CC variants metrics +cc_metrics(out$cc_license_check) +# Obtain cc compliance check resutls metrics +cc_compliance_metrics(out$cc_license_check) +} +\seealso{ +\code{\link[=license_check]{license_check()}} + +Other transform: +\code{\link{cr_compliance_overview}()}, +\code{\link{cr_funder_df}()}, +\code{\link{cr_has_orcid}()}, +\code{\link{cr_tdm_df}()}, +\code{\link{get_license_md}()}, +\code{\link{license_check}()}, +\code{\link{vor_issue}()} +} +\concept{transform} +\keyword{internal} diff --git a/man/cc_compliance_metrics.Rd b/man/cc_compliance_metrics.Rd deleted file mode 100644 index a53300e6..00000000 --- a/man/cc_compliance_metrics.Rd +++ /dev/null @@ -1,29 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/metrics_cc.R -\name{cc_compliance_metrics} -\alias{cc_compliance_metrics} -\title{CC compliance metrics overview} -\usage{ -cc_compliance_metrics(cc_license_check = NULL) -} -\arguments{ -\item{cc_license_check}{tibble, result from \code{\link[=license_check]{license_check()}}} -} -\description{ -Presents the result of the CC compliance check (absolute and relative) -} -\examples{ -# Workflow: -# First, obtain metadata from Crossref API -req <- get_cr_md(tu_dois()[7:10]) - -# Then, check article-level compliance -out <- cr_compliance_overview(req) - -# Obtain CC compliance check resutls metrics -cc_compliance_metrics(out$cc_license_check) -} -\seealso{ -\code{\link[=license_check]{license_check()}} -} -\keyword{internal} diff --git a/man/cc_metrics.Rd b/man/cc_metrics.Rd deleted file mode 100644 index d61f00f6..00000000 --- a/man/cc_metrics.Rd +++ /dev/null @@ -1,32 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/metrics_cc.R -\name{cc_metrics} -\alias{cc_metrics} -\title{CC license variants metrics overview} -\usage{ -cc_metrics(cc_license_check = NULL) -} -\arguments{ -\item{cc_license_check}{tibble, result from \code{\link[=license_check]{license_check()}}} -} -\description{ -Presents normalised CC licence variants like BY (absolute and relative) -} -\examples{ -\dontrun{ -my_dois <- c("10.5194/wes-2019-70", "10.1038/s41598-020-57429-5", - "10.3389/fmech.2019.00073", "10.1038/s41598-020-62245-y", - "10.1109/JLT.2019.2961931") - -# Workflow: -# First, obtain metadata from Crossref API -req <- get_cr_md(my_dois) - -# Then, check article-level compliance -out <- cr_compliance_overview(req) - -# Obtain CC variants metrics -cc_metrics(out$cc_license_check) -} -} -\keyword{internal} diff --git a/man/cr_compliance_overview.Rd b/man/cr_compliance_overview.Rd index 32d44a58..b6245d1b 100644 --- a/man/cr_compliance_overview.Rd +++ b/man/cr_compliance_overview.Rd @@ -14,6 +14,7 @@ Get compliance overview } \seealso{ Other transform: +\code{\link{cc}}, \code{\link{cr_funder_df}()}, \code{\link{cr_has_orcid}()}, \code{\link{cr_tdm_df}()}, diff --git a/man/cr_funder_df.Rd b/man/cr_funder_df.Rd index d8c477b1..1f0c1955 100644 --- a/man/cr_funder_df.Rd +++ b/man/cr_funder_df.Rd @@ -14,6 +14,7 @@ Get funder list from Crossref metadata } \seealso{ Other transform: +\code{\link{cc}}, \code{\link{cr_compliance_overview}()}, \code{\link{cr_has_orcid}()}, \code{\link{cr_tdm_df}()}, diff --git a/man/cr_has_orcid.Rd b/man/cr_has_orcid.Rd index 27355459..86d2e813 100644 --- a/man/cr_has_orcid.Rd +++ b/man/cr_has_orcid.Rd @@ -14,6 +14,7 @@ Check for ORCIDs } \seealso{ Other transform: +\code{\link{cc}}, \code{\link{cr_compliance_overview}()}, \code{\link{cr_funder_df}()}, \code{\link{cr_tdm_df}()}, diff --git a/man/cr_tdm_df.Rd b/man/cr_tdm_df.Rd index 66289c0c..ad4f0276 100644 --- a/man/cr_tdm_df.Rd +++ b/man/cr_tdm_df.Rd @@ -14,6 +14,7 @@ Unnest TDM information for version-of-records from Crossref metadata } \seealso{ Other transform: +\code{\link{cc}}, \code{\link{cr_compliance_overview}()}, \code{\link{cr_funder_df}()}, \code{\link{cr_has_orcid}()}, diff --git a/man/doi_examples.Rd b/man/doi_examples.Rd new file mode 100644 index 00000000..52dbb056 --- /dev/null +++ b/man/doi_examples.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{doi_examples} +\alias{doi_examples} +\title{DOIs included in the package for testing and illustration} +\format{ +A list of \code{\link[biblids:doi]{biblids::doi()}} vectors, including: +\itemize{ +\item \code{good}: Guaranteed to work (all are \code{\link[=is_metacheckable]{is_metacheckable()}}). +\item \code{many}: Long list of DOIs. +\item \code{weird}: Troublesome DOIs. +\item \code{biblids}: \code{\link[biblids:doi_examples]{biblids::doi_examples()}} +} +} +\usage{ +doi_examples +} +\description{ +DOIs included in the package for testing and illustration +} +\examples{ +doi_examples$good + +} +\concept{data} +\keyword{datasets} diff --git a/man/email.Rd b/man/email.Rd index bc589bff..de9d070d 100644 --- a/man/email.Rd +++ b/man/email.Rd @@ -15,7 +15,7 @@ mc_compose_email(translator = mc_translator(), ...) mc_compose_email_outer(body = "Lorem", translator = mc_translator()) mc_render_email( - dois = tu_dois()[1:10], + dois = doi_examples$good[1:10], translator = mc_translator(), session_id = NULL, ... diff --git a/man/funder_metrics.Rd b/man/funder_metrics.Rd index c483f3be..aeeae54f 100644 --- a/man/funder_metrics.Rd +++ b/man/funder_metrics.Rd @@ -19,20 +19,13 @@ Relative number is calculated by the number of checked articles. Articles without funder information are tagged as "No funder links found". } \examples{ -\dontrun{ -## Some DOIs from OA articles -my_dois <- c("10.5194/wes-2019-70", "10.1038/s41598-020-57429-5", - "10.3389/fmech.2019.00073", "10.1038/s41598-020-62245-y", - "10.1109/JLT.2019.2961931") - -# Workflow: # First, obtain metadata from Crossref API -req <- get_cr_md(my_dois) +req <- get_cr_md(doi_examples$good) # Then, check article-level compliance +out <- cr_compliance_overview(req) # Obtain funder metrics overview funder_metrics(out$funder_info) } -} \keyword{internal} diff --git a/man/get_license_md.Rd b/man/get_license_md.Rd index b9c46283..7bd154ff 100644 --- a/man/get_license_md.Rd +++ b/man/get_license_md.Rd @@ -14,6 +14,7 @@ Extract and normalize license info from Crossref metadata } \seealso{ Other transform: +\code{\link{cc}}, \code{\link{cr_compliance_overview}()}, \code{\link{cr_funder_df}()}, \code{\link{cr_has_orcid}()}, diff --git a/man/license_check.Rd b/man/license_check.Rd index a82cc71a..c82170ca 100644 --- a/man/license_check.Rd +++ b/man/license_check.Rd @@ -17,6 +17,7 @@ by the license date. } \seealso{ Other transform: +\code{\link{cc}}, \code{\link{cr_compliance_overview}()}, \code{\link{cr_funder_df}()}, \code{\link{cr_has_orcid}()}, diff --git a/man/metacheck-package.Rd b/man/metacheck-package.Rd index 12a8f35f..89497d57 100644 --- a/man/metacheck-package.Rd +++ b/man/metacheck-package.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/metacheck_package.R +% Please edit documentation in R/metacheck.R \docType{package} \name{metacheck-package} \alias{metacheck} diff --git a/man/metrics_overview.Rd b/man/metrics_overview.Rd index ef2728a7..31f838ba 100644 --- a/man/metrics_overview.Rd +++ b/man/metrics_overview.Rd @@ -25,20 +25,13 @@ The following metrics are presented (absolute and relative): } } \examples{ -\dontrun{ -## Some DOIs from OA articles -my_dois <- c("10.5194/wes-2019-70", "10.1038/s41598-020-57429-5", - "10.3389/fmech.2019.00073", "10.1038/s41598-020-62245-y", - "10.1109/JLT.2019.2961931") - -# Workflow: # First, obtain metadata from Crossref API -req <- get_cr_md(my_dois) +req <- get_cr_md(doi_examples$good) # Then, check article-level compliance +out <- cr_compliance_overview(req) # Finally, obtain compliance metrics overview -metrics_overview(out) -} +metrics_overview(out$cr_overview) } \keyword{internal} diff --git a/man/report.Rd b/man/report.Rd index eac261ee..c3f84875 100644 --- a/man/report.Rd +++ b/man/report.Rd @@ -8,7 +8,7 @@ \usage{ draft_report(lang = mc_langs, ...) -render_report(dois = tu_dois(), translator = mc_translator(), ...) +render_report(dois = doi_examples$good, translator = mc_translator(), ...) } \arguments{ \item{lang}{Character scalar giving the anguage of the report. diff --git a/man/tdm_metrics.Rd b/man/tdm_metrics.Rd index 5bbed2f2..f361b14e 100644 --- a/man/tdm_metrics.Rd +++ b/man/tdm_metrics.Rd @@ -21,20 +21,13 @@ Articles without compliant TDM information are tagged as "No TDM links for version-of-records". } \examples{ -\dontrun{ -## Some DOIs from OA articles -my_dois <- c("10.5194/wes-2019-70", "10.1038/s41598-020-57429-5", - "10.3389/fmech.2019.00073", "10.1038/s41598-020-62245-y", - "10.1109/JLT.2019.2961931") - -# Workflow: # First, obtain metadata from Crossref API -req <- get_cr_md(my_dois) +req <- get_cr_md(doi_examples$good) # Then, check article-level compliance +out <- cr_compliance_overview(req) # Finally, obtain TDM metrics overview tdm_metrics(out$tdm) } -} \keyword{internal} diff --git a/man/tu_dois.Rd b/man/tu_dois.Rd deleted file mode 100644 index 836bfe99..00000000 --- a/man/tu_dois.Rd +++ /dev/null @@ -1,12 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data.R -\name{tu_dois} -\alias{tu_dois} -\title{Some DOIs for testing} -\usage{ -tu_dois() -} -\description{ -Some DOIs for testing -} -\keyword{internal} diff --git a/man/vor_issue.Rd b/man/vor_issue.Rd index 7efeced0..7b14c888 100644 --- a/man/vor_issue.Rd +++ b/man/vor_issue.Rd @@ -17,6 +17,7 @@ record and must be valid without delay. } \seealso{ Other transform: +\code{\link{cc}}, \code{\link{cr_compliance_overview}()}, \code{\link{cr_funder_df}()}, \code{\link{cr_has_orcid}()}, diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index 854b0382..08dc6be6 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -24,7 +24,7 @@ reference: - title: Data desc: Data objects and queries - contents: - - has_concept("doi") + - has_concept("data") - title: Import desc: Read in data - contents: diff --git a/tests/testthat/_snaps/metrics_indexing_status.md b/tests/testthat/_snaps/metrics_indexing_status.md index e8e6b973..f2e2043a 100644 --- a/tests/testthat/_snaps/metrics_indexing_status.md +++ b/tests/testthat/_snaps/metrics_indexing_status.md @@ -11,7 +11,7 @@ "row.names": { "type": "integer", "attributes": {}, - "value": [1, 2, 3, 4, 5] + "value": [1, 2, 3, 4] }, "names": { "type": "character", @@ -26,7 +26,7 @@ "levels": { "type": "character", "attributes": {}, - "value": ["Collaborative Research Center", "Deutsche Forschungsgemeinschaft", "Fundação de Amparo à Pesquisa do Estado de São Paulo", "Tomsk State University", "No funding info"] + "value": ["Collaborative Research Center", "Deutsche Forschungsgemeinschaft", "Fundação de Amparo à Pesquisa do Estado de São Paulo", "No funding info"] }, "class": { "type": "character", @@ -34,17 +34,17 @@ "value": ["factor"] } }, - "value": [1, 2, 3, 4, 5] + "value": [1, 2, 3, 4] }, { "type": "integer", "attributes": {}, - "value": [1, 1, 1, 1, 2] + "value": [1, 1, 1, 3] }, { "type": "double", "attributes": {}, - "value": [20, 20, 20, 20, 40] + "value": [20, 20, 20, 60] } ] } diff --git a/tests/testthat/_snaps/pretest.md b/tests/testthat/_snaps/pretest.md index 4ce360a6..c24d20ea 100644 --- a/tests/testthat/_snaps/pretest.md +++ b/tests/testthat/_snaps/pretest.md @@ -11,7 +11,7 @@ "row.names": { "type": "integer", "attributes": {}, - "value": [1, 2, 3, 4, 5, 6, 7, 8] + "value": [1, 2, 3, 4, 5, 6, 7, 8, 9] }, "names": { "type": "character", @@ -23,37 +23,37 @@ { "type": "logical", "attributes": {}, - "value": [true, false, true, true, true, true, true, true] + "value": [true, false, true, true, true, true, true, true, true] }, { "type": "logical", "attributes": {}, - "value": [true, null, false, true, true, true, true, true] + "value": [true, null, false, true, true, true, true, true, true] }, { "type": "logical", "attributes": {}, - "value": [true, null, null, true, true, false, false, false] + "value": [true, null, null, true, true, false, false, false, false] }, { "type": "logical", "attributes": {}, - "value": [true, null, null, true, true, null, null, null] + "value": [true, null, null, true, true, null, null, null, null] }, { "type": "logical", "attributes": {}, - "value": [false, null, null, true, false, null, null, null] + "value": [false, null, null, true, false, null, null, null, null] }, { "type": "logical", "attributes": {}, - "value": [null, null, null, true, null, null, null, null] + "value": [null, null, null, true, null, null, null, null, null] }, { "type": "logical", "attributes": {}, - "value": [null, null, null, true, null, null, null, null] + "value": [null, null, null, true, null, null, null, null, null] } ] } @@ -63,7 +63,7 @@ { "type": "logical", "attributes": {}, - "value": [false, false, false, true, false, false, true, true] + "value": [false, false, false, true, false, false, true, true, false] } # DOI acceptability is reported @@ -77,6 +77,6 @@ "value": ["glue", "character"] } }, - "value": ["- 7 (88%) thereof fulfill the criterion `not_missing` (**1** dropped)\n- 6 (86%) thereof fulfill the criterion `unique` (**1** dropped)\n- 6 (100%) thereof fulfill the criterion `within_limits` (**0** dropped)\n- 6 (100%) thereof fulfill the criterion `doi_org_found` (**0** dropped)\n- 3 (50%) thereof fulfill the criterion `from_cr` (**3** dropped)\n- 3 (100%) thereof fulfill the criterion `cr_md` (**0** dropped)\n- 3 (100%) thereof fulfill the criterion `article` (**0** dropped)"] + "value": ["- 8 (89%) thereof fulfill the criterion `not_missing` (**1** dropped)\n- 7 (88%) thereof fulfill the criterion `unique` (**1** dropped)\n- 7 (100%) thereof fulfill the criterion `within_limits` (**0** dropped)\n- 6 (86%) thereof fulfill the criterion `doi_org_found` (**1** dropped)\n- 3 (50%) thereof fulfill the criterion `from_cr` (**3** dropped)\n- 3 (100%) thereof fulfill the criterion `cr_md` (**0** dropped)\n- 3 (100%) thereof fulfill the criterion `article` (**0** dropped)"] } diff --git a/tests/testthat/test-data.R b/tests/testthat/test-data.R new file mode 100644 index 00000000..abebe256 --- /dev/null +++ b/tests/testthat/test-data.R @@ -0,0 +1,3 @@ +test_that("Good example DOIs are all metacheckable", { + expect_true(all(is_metacheckable(doi_examples$good))) +}) diff --git a/tests/testthat/test-import.R b/tests/testthat/test-import.R index dc2bde5e..0f7501ff 100644 --- a/tests/testthat/test-import.R +++ b/tests/testthat/test-import.R @@ -1,7 +1,7 @@ # wrapped cr api calls ==== skip_if_offline() -dois <- tu_dois()[2:5] +dois <- doi_examples$good[2:5] test_that("Crossref metadata can be read in", { # testthat does not seem to know about vctrs equality @@ -24,8 +24,8 @@ test_that("cr_works2 throws error on bad DOIs", { }) test_that("cr_works accepts only one doi (lonely)", { - expect_error(lonely_cr_works(dois[2:3])) - expect_type(lonely_cr_works(dois[2]), "list") + expect_error(lonely_cr_works(as.character(dois[2:3]))) + expect_type(lonely_cr_works(as.character(dois[2])), "list") }) test_that("cr_works captures warnings (quiet)", { @@ -34,14 +34,14 @@ test_that("cr_works captures warnings (quiet)", { regexp = "404" ) expect_equal( - quiet_cr_works(dois[2])$warnings, + quiet_cr_works(as.character(dois[2]))$warnings, character() ) }) test_that("cr_works fails on bad output or warning (prickly)", { expect_error(prickly_cr_works("10.1000/foo")) - expect_type(prickly_cr_works(dois[2]), "list") + expect_type(prickly_cr_works(as.character(dois[2])), "list") }) test_that("cr_works retries on bad output (insistently)", { @@ -52,7 +52,8 @@ test_that("cr_works retries on bad output (insistently)", { }) test_that("cr_works uses cache (memoised)", { - random_doi <- as.character(sample(dois_many(), size = 1)) + skip("Test is not deterministic") + random_doi <- as.character(sample(doi_examples$many, size = 1)) before <- system.time(memoised_cr_works(random_doi))["elapsed"] after <- system.time(memoised_cr_works(random_doi))["elapsed"] expect_lt(after, before / 10L) @@ -60,7 +61,9 @@ test_that("cr_works uses cache (memoised)", { test_that("cr_works_field can find fields", { expect_true( - biblids::as_doi(cr_works_field(dois[1], "doi")) == biblids::as_doi(dois[1]) + biblids::as_doi( + cr_works_field(as.character(dois[1]), "doi") + ) == biblids::as_doi(dois[1]) ) }) @@ -73,7 +76,7 @@ test_that("cr_works_field defaults to NA for errors", { test_that("many cr_works_fields can be retrieved", { expect_equal( - looped_possibly_cr_works_field(c("10.1000/foo", dois[1]), "doi"), - c(NA, dois[1]) + looped_possibly_cr_works_field(c("10.1000/foo", as.character(dois[1])), "doi"), + c(NA, as.character(dois[1])) ) }) diff --git a/tests/testthat/test-metrics_indexing_status.R b/tests/testthat/test-metrics_indexing_status.R index 5086bac3..0a3e57ab 100644 --- a/tests/testthat/test-metrics_indexing_status.R +++ b/tests/testthat/test-metrics_indexing_status.R @@ -1,6 +1,6 @@ skip_if_offline() -test_dois <- tu_dois()[2:6] +test_dois <- doi_examples$good[2:6] req <- get_cr_md(test_dois) out <- cr_compliance_overview(req) diff --git a/tests/testthat/test-pretest.R b/tests/testthat/test-pretest.R index 05754521..c3e82ab3 100644 --- a/tests/testthat/test-pretest.R +++ b/tests/testthat/test-pretest.R @@ -2,19 +2,19 @@ skip_if_offline() test_that("Acceptable DOIs are filtered", { - expect_snapshot_value2(tabulate_metacheckable(dois_weird(), limit = 3)) - expect_snapshot_value2(is_metacheckable(dois_weird(), limit = 3)) + expect_snapshot_value2(tabulate_metacheckable(doi_examples$weird, limit = 3)) + expect_snapshot_value2(is_metacheckable(doi_examples$weird, limit = 3)) }) test_that("Acceptable DOIs can be asserted", { - expect_error(assert_metacheckable(dois_weird())) + expect_error(assert_metacheckable(doi_examples$weird)) expect_invisible( - assert_metacheckable(dois_weird()[is_metacheckable(dois_weird())]) + assert_metacheckable(doi_examples$weird[is_metacheckable(doi_examples$weird)]) ) }) test_that("DOI acceptability is reported", { - expect_snapshot_value2(report_metacheckable(dois_weird())) + expect_snapshot_value2(report_metacheckable(doi_examples$weird)) }) # custom predicates ==== diff --git a/vignettes/bericht.Rmd b/vignettes/bericht.Rmd index 007c0c24..1d43f431 100644 --- a/vignettes/bericht.Rmd +++ b/vignettes/bericht.Rmd @@ -7,7 +7,7 @@ pkgdown: ```{r, echo = FALSE, results = 'asis', message = FALSE} diff --git a/vignettes/report.Rmd b/vignettes/report.Rmd index 8efe655f..89aac4cf 100644 --- a/vignettes/report.Rmd +++ b/vignettes/report.Rmd @@ -7,7 +7,7 @@ pkgdown: ```{r, echo = FALSE, results = 'asis', message = FALSE}