api_get_provenance_metadata is a fantastic resource but I ran into a case where I needed to access provenance information but had the doi and/or url of the dataset rather than the project identifier (e.g., knb-lter-xxx.x.x). Below is an R-based MRE using a dataset from BNZ that I used to address this task but it seems that the utility of api_get_provenance_metadata would be increased if it would natively accept a dataset doi or url in addition to the project ### identifier.
MRE (in R):
library(rvest)
library(EDIutils)
library(EML)
library(dplyr)
library(stringr)
url <- "https://doi.org/10.6073/pasta/31b32868ddbb099c4b5480fb00eb2481"
landingPage <- read_html(url)
pageSubset <- landingPage %>%
html_nodes(".no-list-style") %>%
html_text()
packageId <- str_extract(grep("knb-lter-", pageSubset, value = TRUE)[[1]], "^\\S*")
packageProv <- emld::as_emld(EDIutils::api_get_provenance_metadata(packageId))
packageProv$`@context` <- NULL
packageProv$`@type` <- NULL
# desired output
packageProv
api_get_provenance_metadatais a fantastic resource but I ran into a case where I needed to access provenance information but had the doi and/or url of the dataset rather than the project identifier (e.g., knb-lter-xxx.x.x). Below is an R-based MRE using a dataset from BNZ that I used to address this task but it seems that the utility ofapi_get_provenance_metadatawould be increased if it would natively accept a dataset doi or url in addition to the project ### identifier.MRE (in R):