diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..be448ea --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,2 @@ +^EMLeditor\.Rproj$ +^\.Rproj\.user$ diff --git a/.Rhistory b/.Rhistory new file mode 100644 index 0000000..6463d86 --- /dev/null +++ b/.Rhistory @@ -0,0 +1,3 @@ +library(devtools) +install.packages("roxygen") +library(roxygen) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cd67eac --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.Rproj.user diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..5842151 --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,20 @@ +Package: EMLeditor +Title: View and Edit EML +Version: 0.0.0.9000 +Authors@R: + person("Robert", "Baker", , "robert_baker@nps.gov", role = c("aut", "cre"), + comment = c(ORCID = "0000-0001-7591-5035")) +Description: This package will be of most use to the U.S. National Park Service. EML-formatted .xml files are typically constructed using EDI's EMLassemblyline package and then imported as an R-object using the EML package. EMLeditor allows the user to view the contents of the R object and add aspects of metadata crucial for publication in the U.S. National Park Service DataStore repository. For instance, a user can view and edit a DOI, a link to a DRR, Park Unit connections, information about Confidential Unclassified Information (CUI), and more. EMLeditor allows the user to write a mockup of a README.txt to preview what the README automatically generated by DataStore upon upload will look like. +License: `use_mit_license()`, `use_gpl3_license()` or friends to pick a + license +Encoding: UTF-8 +Roxygen: list(markdown = TRUE) +RoxygenNote: 7.2.0 +Depends: + EML, + arcticdatautils, + magrittr, + stringr, + gdata, + stargazer +Remotes: NCEAS/arcticdatautils diff --git a/EMLeditor.Rproj b/EMLeditor.Rproj new file mode 100644 index 0000000..69fafd4 --- /dev/null +++ b/EMLeditor.Rproj @@ -0,0 +1,22 @@ +Version: 1.0 + +RestoreWorkspace: No +SaveWorkspace: No +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX + +AutoAppendNewline: Yes +StripTrailingWhitespace: Yes +LineEndingConversion: Posix + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source +PackageRoxygenize: rd,collate,namespace diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..cdda6bd --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,21 @@ +# Generated by roxygen2: do not edit by hand + +S3method(edit,DOI) +export(eml_getNPS) +export(eml_get_simpleNPS) +export(get.CUI) +export(get.DOI) +export(get.DRRdoi) +export(get.DSRefID) +export(get.abstract) +export(get.authorList) +export(get.beginDate) +export(get.citation) +export(get.endDate) +export(get.fileInfo) +export(get.parkUnits) +export(get.title) +export(set.CUI) +export(set.DOI) +export(set.DRRdoi) +export(set.parkUnits) diff --git a/R/editEMLfunctions.R b/R/editEMLfunctions.R new file mode 100644 index 0000000..a21420e --- /dev/null +++ b/R/editEMLfunctions.R @@ -0,0 +1,155 @@ +#' Check & set a DOI +#' +#' @details +#' This function checks to see if there is a DOI in the tag. The EMLassemblyline package stores datapackage DOIs in this tag (although the official EML schema has the DOI in a different location). If there is no DOI in the tag, the function adds a DOI. If there is a DOI, the function alerts the users to this fact, reports the existing DOI, and suggests using a separate function to edit an existing DOI (edit.DOI()). +#' +#' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(, from="xml"). +#' @param DOI is the same as the 7-digit reference code generated on DataStore when a draft reference is initiated. Don't worry about the https://wwww.doi.org and the datapackage prefix - those will all automatically be added in by the function. +#' @returns an EML-formatted R object +#' @export +set.DOI<-function(emlObject, DOI){ + doc<-arcticdatautils::eml_get_simple(emlObject, "alternateIdentifier") #where EMLassemblyline stores DOIs. + #if a DOI exists, report that it already exists and prompt to edit: + if(!is.null(doc)){ + mylist<-NULL + #doc<-unlist(doc) + if(length(doc)>1){ + for(i in 1:length(names(doc))){ + if(stringr::str_detect(doc[i], "doi:" )){ + mylist<-append(mylist, doc[i]) + } + } + } + else{ + mylist<-doc + } + doi<-mylist[[1]] + cat("Your EML already has a DOI specified in the tag:\n", doi, "\n\nIf this is correct, no further action is needed. To edit your existing DOI, run \'edit.DOI()\'") + } + #if there is no DOI, add it directly: + else{ + emlObject$dataset$alternateIdentifier<-paste0("doi: https://doi.org/10.57830", DOI) + } + return(emlObject) +} + +#' Force-edits an existing DOI +#' +#' @description edit.DOI forces changes to an existing DOI +#' +#' @details +#' If a DOI already exists in the tag (get.DOI() to check), this allows the user to over-write the existing DOI. WARNING: will cause loss of the system="https://doi.org" setting. So only use this if you really don't already have a DOI. +#' +#' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(, from="xml"). +#' @param DOI is the same as the 7-digit reference code generated on DataStore when a draft reference is initiated. Don't worry about the https://wwww.doi.org and the datapackage prefix - those will all automatically be added in by the function. +#' @returns an EML-formatted R object +#' @export +edit.DOI<-function(emlObject, DOI){ + emlObject$dataset$alternateIdentifier<-paste0("doi:", DOI) + return(emlObject) +} + + +# Add Park Unit Connections to metadata +#if geographic coverage exists, add to it. +#if geographic coverage exists, doesn't yet add in id= attribute. Grr. + +#' Adds Park Unit Connections to metadata +#' +#' @details +#' Add the Park Unit Connection(s) to a tag under . Park Unit Connection(s) are the (typically) four-letter codes describing the park unit(s) where data were collected (e.g. ROMO, not ROMN). If there are already =items listed under geographicCoverage, Park Unit Connections will be inserted as the first item in the list of geographicCoverages and will be prefaced by the string "NPS Unit Connections:". +#' +#' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(, from="xml"). +#' @param ParkUnits a string of comma-separated park unit codes +#' @returns an EML-formatted R object +#' @export +#' @examples +#' ParkUnits<-("ROMO, GRSD, TRYME") +#' set.parkUnits(emlObject, ParkUnits) +set.parkUnits<-function(emlObject, ParkUnits){ + #get geographic coverage from emlObject + doc<-EML::eml_get(emlObject, "geographicCoverage") + + #if there is no geo coverage, add it directly to emlObject + if(is.null(doc)){ + emlObject$dataset$coverage$geographicCoverage$id<-"UnitConnections" + emlObject$dataset$coverage$geographicCoverage$geographicDescription<-paste0("NPS Unit Connections: ",ParkUnits) + } + + #if there are already geographicCoverage(s) + #(unfortunately currently there is no way to ad id="UnitConnections" in this case) + else{ + mylist<-NULL + #ditch the '@context' list from the goeCoverage: + for(i in 1:length(names(doc))){ + if(!names(doc)[i]=='@context') + mylist<-append(mylist, doc[i]) + } + #remove names from list (critical for writing back to xml) + names(mylist)<-NULL + + #add text to indicate that these are park unit connections: + units<-paste0("NPS Unit Connections: ", ParkUnits) + + #generate the new geographic coverage elements: + geocov2<-list(geographicDescription=units) + + #combine new and old geo coverages (new always at the top!) + mylist<-append(list(geocov2), mylist) + + #write over the existing geographic coverage + emlObject$dataset$coverage$geographicCoverage<-mylist + } + return(emlObject) +} + +#' Adds CUI to metadata +#' +#' @description set.CUI adds CUI codes to EML metadata +#' +#' @details set.CUI adds a CUI code to the tag under . +#' +#' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(, from="xml"). +#' @param CUI a string consisting of one of 5 potential CUI codes. Pay attention to the spaces: +#' FED ONLY - Contains CUI. Only federal employees should have access (similar to "internal only" in DataStore) +#' FEDCON - Contains CUI. Only federal employees and federal contractors should have access (also very much like current "internal only" setting in DataStore) +#' DL ONLY - Contains CUI. Should only be available to a names list of individuals (where and how to list those individuals TBD) +#' NOCON - Contains CUI. Federal, state, local, or tribal employees may have access, but contractors cannot. +#' PUBVER - Does NOT contain CUI. The original data contained CUI, but in this datapackage CUI have been obscured so that it no longer contains CUI. +#' PUBFUL - Does NOT contain CUI. The original data contained no CUI. No data were obscured or altered to generate the data package +#' @returns an EML-formatted R object +#' @export +#' @examples +#' set.CUI(emlObject, "PUBFUL") +set.CUI<-function(emlObject, CUI){ + #add those random spaces in case people forget + if(CUI=="FEDONLY"){ + CUI=="FED ONLY" + } + if(CUI=="DLONLY"){ + CUI=="DL ONLY" + } + #add CUI to EML + emlObject$additionalMetadata$metadata$CUI<-CUI + return(emlObject) +} + + + +#' adds DRR connection +#' +#' @description set.DRRdoi adds the DOI of an associated DRR +#' +#' @details adds uses the DataStore Reference ID for an associate DRR to the as a properly formatted DOI (prefaced with "DRR: ") to the tag. ####CAUTION: in the current implimentation this may overwrite any other useageCitation info. +#' +#' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(, from="xml"). +#' @param DRRrefID a 7-digit string that is the DataStore Reference ID for the DRR associated with the datapackage. +#' @returns an EML-formatted R object +#' @export +#' @examples +#' set.DRRdoi(emlObject, "2293234") +set.DRRdoi<-function(emlObject, DRRrefID){ + doi<-paste0("DRR: https://doi.org/10.57830", DRRdoi) + emlObject$dataset$useageCitation<-doi + return(emlObject) +} diff --git a/R/getEMLfunctions.R b/R/getEMLfunctions.R new file mode 100644 index 0000000..3564222 --- /dev/null +++ b/R/getEMLfunctions.R @@ -0,0 +1,373 @@ +#' returns the first date +#' +#' @description get.beginDate returns the date of the earliest data point in the datapackage +#' +#' @details returns the date from the tag. Although dates should be formatted according to ISO-8601 (YYYY-MM-DD) it will also check for a few other common formats and return the date as a text string: "DD Month YYYY" +#' +#' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(, from="xml"). +#' @return a text string +#' @export +#' @examples +#' get.beginDate(emlObject) +get.beginDate<-function(emlObject){ + begin<-arcticdatautils::eml_get_simple(emlObject, "beginDate") %>% as.Date %>% format("%d %B %Y") +} + +#' returns the last date +#' +#' @description get.endDate returns the date of the last data point in the datapackage +#' +#' @details returns the date from the tag. Although dates should be formatted accoriding to ISO-8601 (YYYY-MM-DD) it will also check a few other common formats and return the date as a text string: "DD Month YYYY" +#' +#' #' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(, from="xml"). +#' @return a text sting +#' @export +#' @examples +#' get.endDate(emlObject) +get.endDate<-function(emlObject){ + begin<-arcticdatautils::eml_get_simple(emlObject, "endDate") %>% as.Date %>% format("%d %B %Y") +} + + +#' returns the abstract +#' +#' @description returns the text from the tag. +#' +#' @details returns the text from the tag and attempts to clean up common text issues, such as enforcing UTF-8 formatting, getting rid of carriage returns, new lines, and tags and mucks about with layout, line breaks, etc. IF you see characters you don't like in the abstract, make sure to edit your abstract in a text editor (e.g. Notepad and NOT a Word). You should save the text to a new object and view it using writeLines() +#' +#' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(, from="xml"). +#' @return a text string +#' @export +#' @example +#' abstract<-get.abstract(emlObject) +#' writeLines(abstract) +get.abstract<-function(emlObject){ + doc<-arcticdatautils::eml_get_simple(emlObject, "abstract") + if(is.null(doc)){ + stop("Your EML lacks an abstract. Use set.abstract() to add one.") + } + + Encoding(doc)<-"UTF-8" #helps with weird characters + txt<-NULL + for(i in 1:length(doc)){ + if(nchar(doc[i])>0){ + mypara <- gsub("[\r?\n|\r]", "", doc[i]) #get rid of line breaks and carriage returns + mypara <- gsub(" ", " ", mypara) #get rid of carriage symbols + mypara <- gsub("&#13;", ". ", mypara) + mypara <- gsub("", "", mypara) #get rid of literalLayout tag + mypara <- gsub("", "", mypara) #get rid of para tag + mypara <- gsub("", "", mypara) #get rid of close para tag + mypara <- gsub("", "", mypara) #get rid of close par tag + txt<-paste(txt, mypara, sep="\n\n\t") + } + } + return(txt) +} + +#' returns the datapackage title +#' +#' @description returns a text string that is the title of the datapackage +#' +#' @details accesses all of the tags (there can be several, if each file was given a separate title). Assumes that the first instance of <title> referes to the entire datapackage and returns it as a text string, ignoring the contents of all other <title> tags. +#' +#' #' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml"). +#' @return a text string +#' @export +#' @example +#' get.title(emlObject) +get.title<-function(emlObject){ + doc<-arcticdatautils::eml_get_simple(emlObject, "title")[1] +} + +#' returns the DataStore Reference ID +#' +#' @description get.DSRefID returns the DataStore Reference ID as a string of text. +#' +#' @details accesses the DOI listed in the <alternateIdentifier> tag and trims to to the last 7 digits, which should be identical to the DataStore Reference ID. If the <alternateIdentifier> tag is empty, it notifies the user that there is no DOI associate with the metadata and suggests adding one using set.DOI() (edit.DOI() would also work). +#' +#' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml"). +#' @return a text string +#' @export +#' @example +#' get.DSRefID(emlObject) +get.DSRefID<-function(emlObject){ + pid<-arcticdatautils::eml_get_simple(emlObject, "alternateIdentifier") + if(is.null(pid)){ + stop("Your EML lacks a DOI in the \"alternateIdentifier\" tag.\n Please use the set.DOI() function to add your DOI") + } + for(i in 1:length(pid)){ + if(stringr::str_detect(pid[i], "doi:10.")){ + doi<-pid[i] + } + } + RefID<-stringr::str_sub(doi, start=-7) + return(RefID) +} + +#' returns the datapackage citation +#' +#' @description returns a Chicago manual of style citation for the datapackage +#' +#' @details allows the user to preview the what the citation will look like. The Harper's Ferry Style Guide recommends using the Chicago Manual of Style for formatting citations. The citation is formatted according to to a modified version of the Chicago Manual of Style's Author-Date journal article format because currently there is no Chicago Manual of Style format specified for datasets or datapackages. In compliance wiht DataCite's recommendations regarding including DOIs in citations, the citation displays the entire DOI as https://www.doi.org/10.58370/xxxxxx". +#' +#' #' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml"). +#' @return a text string +#' @export +#' @example +#' get.citation(emlObject) +get.citation<-function(emlObject){ + #assemble the pieces: + + pid<-get.DOI(emlObject) + + authorList<-get.authorList(emlObject) + + title<-get.title(emlObject) + + pubDate<-arcticdatautils::eml_get_simple(emlObject, "pubDate") + pubDate<-lubridate::parse_date_time(pubDate, orders="Y-m-d") + pubYear<-lubridate::year(pubDate) + + publisher<-"The U.S National Park Service. " + + location<-"Fort Collins, CO. " + #print(location) + + #### what to do if no doi ("set" eml?)? + + #print(doi) + + #piece it together: + data.Citation<-paste0(authorList, " ", pubYear, ". ", title, ". ", publisher, location, doi) + + return(data.Citation) +} + +#' returns the authors +#' +#' @description get.authorList returns a text string with all of the authors listed under the <creator> tag. +#' +#' @details get.authorList assumes every author has at least 1 first name (either <givenName> or <givenName1>) and only one last name (<surName>). Middle names (<givenName2>) are optional. The author List is formatted with the last name, comma, first name for the first author and the fist name, last name for all subsequent authors. The last author's name is preceeded by an 'and'. +#' +#' #' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml"). +#' @return a text string +#' @export +#' @example +#' get.authorList(emlObject) +get.authorList<-function(emlObject){ + #get author names & affiliations + authors<-arcticdatautils::eml_get_simple(emlObject, "creator") + authors<-unlist(authors) + + #extract givenName; should handle middle names too! + FirstName<-NULL + first<-NULL + for(i in 1:length(authors)){ + if(stringr::str_detect(names(authors)[i], "givenName\\b")){ + FirstName<-append(FirstName, authors[i][[1]]) + } + else if(stringr::str_detect(names(authors)[i], "givenName1\\b")){ + first_middle<-paste0(authors[i], " ", authors[i+1]) + FirstName<-append(FirstName, first_middle) + } + + if(length(first>0)){ + first_middle<-paste0(first, " ", middle) + FirstName<-append(FirstName, first_middle) + } + } + + #extract surName + LastName<-NULL + for(i in 1:length(authors)){ + if(stringr::str_detect(names(authors)[i], "surName")){ + LastName<-append(LastName, authors[i][[1]]) + } + } + + #create a single object that is a string consisting of the ith author, formatted according to the Chicago manual of style, Journal article: + + author<-NULL + Last.First<-NULL + if(length(LastName)>0){ + #single author: + if(length(LastName)==1){ + author<-paste0(LastName, ", ", FirstName, ".") + Last.First<-author + } + + #multi-author: + else{ + for(i in 1:length(LastName)){ + if(i==1){ + } + if(i>1 && i<length(LastName)){ + author<-paste0(FirstName[i], " ", LastName[i]) + } + if(i>1 && i==length(LastName)){ + author<-paste0("and ", FirstName[i], " ", LastName[i], ".") + } + Last.First<-append(Last.First, author) + } + + #make it a string, not a list: + Last.First<-toString(Last.First) + } + } + + +} + +#' returns the DOI +#' +#' @description returns a text string that is the DOI for the datapackage +#' +#' @details accesses the contents of the<alternateIdentifier> tag and does some text manipulation to return a string with the DOI including the URL and prefaced by 'doi: '. +#' +#' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml"). +#' @return a text string +#' @export +#' @example +#' get.DOI(emlObject) +get.DOI<-function(emlObject){ + #where EMLassemblyline stores DOIs. + doc<-arcticdatautils::eml_get_simple(emlObject, "alternateIdentifier") + + #if a DOI exists, report that it already exists and prompt to edit: + if(!is.null(doc)){ + mylist<-NULL + if(length(doc)>1){ + for(i in 1:length(names(doc))){ + if(stringr::str_detect(doc[i], "doi:" )){ + mylist<-append(mylist, doc[i]) + } + } + } + else{ + mylist<-doc + } + doi<-mylist[[1]] + doi<-gsub('doi:', 'https://doi.org/', doi) + } +} + +#' returns the park unit connections +#' +#' @description returns a string with the park unit codes where the data were collected +#' +#' @details accesses the contents of the <geographicDescription> tags and returns the contents of the tag that containst the text "NPS Unit Connections". If there is no <geographicDescription>, it alerts the user and suggests adding park unit connections using the set.parkUnits() function. +#' +#' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml"). +#' @return a text string +#' @export +#' @example +#' get.parkUnits(emlObject) +get.parkUnits<-function(emlObject){ + units<-arcticdatautils::eml_get_simple(emlObject, "geographicDescription")[[1]] + punits<-NULL + for(i in 1:length(units)){ + if(stringr::str_detect(units[i], "NPS Unit Connections:")){ + punits<-units[i] + } + } + if(is.null(punits)){ + stop("Your EML does not appear to have NPS Unit Connections specified. Please use set.parkUnits() to add unit connections") + } + return(punits[[1]]) +} + +#' returns a CUI statement +#' +#' @description get.CUI returns an english-language translation of the CUI codes +#' +#' @details get.CUI accesses the contents of the Controlled Unclassified Information (CUI) tag, <CUI> and returns an appropriate string of english-language text based on the properties of the CUI code. If thee <CUI> tag is empty or does not exist, get.CUI alerts the user and suggests specifying CUI using the set.CUI() funciton. +#' +#' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml"). +#' @return a text string +#' @export +#' @example +#' get.CUI(emlObject) +get.CUI<-function(emlObject){ + cui<-arcticdatautils::eml_get_simple(emlObject, "CUI") + if(is.null(cui)){ + stop("No CUI specified. Use the set.CUI() function to add a properly formatted CUI code.") + } + if(cui=="FED ONLY"){ + cui<-"Contains CUI. Only federal employees should have access (similar to \"internal only\" in DataStore)" + } + if(cui=="FEDCON"){ + cui<-"Contains CUI. Only federal employees and federal contractors should have access (also very much like current \"internal only\" setting in DataStore)" + } + if(cui=="DL ONLY"){ + cui<-"Contains CUI. Should only be available to a names list of individuals (where and how to list those individuals TBD)" + } + if(cui=="NOCON"){ + cui<-"Contains CUI. Federal, state, local, or tribal employees may have access, but contractors cannot." + } + if(cui=="PUBVER"){ + cui<-"Does NOT contain CUI. The original data contained CUI, but in this datapackage CUI have been obscured so that it no longer contains CUI." + } + if(cui=="PUBFUL"){ + cui<-"Does NOT contain CUI. The original data contained no CUI. No data were obscured or altered to generate the data package." + } + return(cui) +} + + +#' displays file names, sizes, and descriptions +#' +#' @description returns a plain-text table containing file names, file sizes, and short descriptions of the files. +#' +#' @details returns the file names (listed in the <objectName> tag), the size of the files (listed in the <size> tag) and converts it from bytes (B) to a more easily interpretable unit (KB, MB, GB, etc). Technically this uses powers of 2^10 so that KB is actually a kibibyte (1024 bytes) and not a kilobyte (1000 bytes). Similarly MB is a mebibyte not a megabyte, GB is a gibibyte not a gigabyte, etc. But for most practical purposes this is probably irrelevant. Finally, a short description is provided for each file (from the <entityDescription> tag). +#' +#' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml"). +#' @return a text string +#' @export +#' @example +#' get.fileInfo(emlObject) +#gets & displays the filenames (from objectName) and file descriptions (from entityDescription): +get.fileInfo<-function(emlObject){ + #get file names + file.name<-arcticdatautils::eml_get_simple(emlObject, "objectName") + + #get file sizes (assumes in bytes) + filesize<-arcticdatautils::eml_get_simple(emlObject, "size") + filesize<-suppressWarnings(as.numeric(filesize)) + filebyte<-unique(filesize) + filebyte<-filebyte[!is.na(filebyte)] + readable<-gdata::humanReadable(filebyte, standard="Unix") %>% + paste0("B") + + #get file descriptions + file.descript<-arcticdatautils::eml_get_simple(emlObject, "entityDescription") + + #generate dataframe for display: + dat<-data.frame(file.name, readable, file.descript) + colnames(dat)<-c("FileName", "Size", "Description") + + print("Current filenames and file descriptions:") + print(dat) +} + +#' returns the DOI of the associated DRR +#' +#' @description get.DRRdoi returns a text string with the associated Data Release Report (DRR)'s DOI. +#' +#' @details get.DRRdoi accesses the <useageCitation> tag(s) and searches for the string "DRR: https://doi.org/". If that string is found, the contenst of that tag are returned. If the <useageCitation> tag is empty or not present, the user is informed and pointed to the set.DRRdoi() function to add the DOI of an associated DRR. +#' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml"). +#' @return a text string +#' @export +#' @example +#' get.DRRdoi(emlObject) +get.DRRdoi<-function(emlObject){ + doi<-arcticdatautils::eml_get_simple(emlObject, "useageCitation") + if(is.null(doi)){ + stop("You have not specified a DRR associated with this datapackage. To specify a DRR, use set.DRRdoi().") + } + for(i in 1:length(doi)){ + if(stringr::str_detect(doi[i], "DRR: https://doi.org/")){ + DRRdoi<-doi[i] + } + } + return(DRRdoi) +} diff --git a/R/utils.R b/R/utils.R new file mode 100644 index 0000000..47b3979 --- /dev/null +++ b/R/utils.R @@ -0,0 +1,21 @@ +#' alias for eml_get_simple +#' +#' @decription eml_get_simpleNPS is an alias for arcticdatautils eml_get_simple function +#' +#' @details eml_get_simpleNPS serves as an alias for the arcticdatautils function eml_get_simple. This means the eml_get_simple() function will be called using current local version of arcticdatautils on the users's machine rather than whatever version was available when the package was built. +#' +#' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml"). +#' @param elment is the name of the element to be extracted. If multiple occurances are found, will extract all. +#' @export +eml_get_simpleNPS<-function(...)arcticdatautils::eml_get_simple() + +#' alias for eml_get +#' +#' @decription eml_getNPS is an alias for the EML get_simple function +#' +#' @details eml_getNPS serves as an alias for the EML function eml_get. This means the eml_get() function will be called using current local version of EML on the users's machine rather than whatever version was available when the package was built. +#' +#' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml"). +#' @param elment is the name of the element to be extracted. If multiple occurrences are found, will extract all. +#' @export +eml_getNPS<-function(...)EML::eml_get() diff --git a/R/writeReadMe.R b/R/writeReadMe.R new file mode 100644 index 0000000..ee73dd9 --- /dev/null +++ b/R/writeReadMe.R @@ -0,0 +1,65 @@ +############################################################################### +############################################################################### +################# write.readMe() writes a text file ########################### +############################################################################### +############################################################################### + +#emlObject is an R object read in from a *.metadata.xml file formatted as EML using the EML::read_eml() function. +#outfile is the name of the file you want to write to, in quotes. Typically, "ReadMe.txt" + +#example: +#emldoc<-EML::read_eml("ReadMeTest.xml", from="xml") +#write.readMe(emldoc, "ReadMe2.txt") + +write.readMe<-function(emlObject, outfile){ + + #get components: + Ref<-get.DSRefID(emlObject) #Data Store Ref. ID + doi<-get.DOI(emlObject) #DOI + title<-get.title(emlObject) #title + abstract<-get.abstract(emlObject) #abstract + fileInfo<-get.fileInfo(emlObject) #names, sizes, descriptions + start<-get.beginDate(emlObject) #content start date + end<-get.endDate(emlObject) #content end date + units<-get.parkUnits(emlObject) #park units where data were collected + CUI<-get.CUI(emlObject) #controlled unclassified information status + DRRdoi<-get.DRRdoi(emlObject) #DOI of accompanying DRR + citation<-get.citation(emlObject) #citation + + #Write to the components to the textfile specified in "outfile". + cat(paste0("ReadMe file for DataStore reference# ", Ref), file=outfile, sep="\n") + + cat(paste0("Digital Object Identifier (DOI): ", doi, "\n"), file=outfile, sep="\n", append=TRUE) + + cat("Title:", file=outfile, sep="\n", append=TRUE) + + cat(paste0(title, "\n"), file=outfile, sep="\n", append=TRUE) + + cat("Abstract:", file=outfile, sep="\n", append=TRUE) + + cat(abstract, file=outfile, sep="\n", append=TRUE) + + cat(paste0("\n", "Files:"), file=outfile, sep="\n", append=TRUE) + + cat(stargazer::stargazer(fileInfo, summary=FALSE, type="text"), file=outfile, sep="\n", append=TRUE) + + cat("\nContent:", file=outfile, sep="\n", append=TRUE) + + cat(paste0("Begin date: ", start), file=outfile, sep="\n", append=TRUE) + + cat(paste0("End date: ", end), file=outfile, sep="\n", append=TRUE) + + cat(units, file=outfile, sep="\n", append=TRUE) + + cat(paste0("Sensitivity: ", CUI), file=outfile, sep="\n", append=TRUE) + + cat(paste0("Data Quality: Information about production and quality of this product can be found in the Data Release Report (DRR) at: ", DRRdoi, "\n"), file=outfile, sep="\n", append=TRUE) + + cat("\nCitation:\n", file=outfile, sep="\n", append=TRUE) + + cat(citation, file=outfile, sep="\n", append=TRUE) +} + +############################################################################### +####################### end write.readMe() #################################### +############################################################################### diff --git a/man/edit.DOI.Rd b/man/edit.DOI.Rd new file mode 100644 index 0000000..5fab3a8 --- /dev/null +++ b/man/edit.DOI.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/editEMLfunctions.R +\name{edit.DOI} +\alias{edit.DOI} +\title{Force-edits an existing DOI} +\usage{ +\method{edit}{DOI}(emlObject, DOI) +} +\arguments{ +\item{emlObject}{is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml").} + +\item{DOI}{is the same as the 7-digit reference code generated on DataStore when a draft reference is initiated. Don't worry about the https://wwww.doi.org and the datapackage prefix - those will all automatically be added in by the function.} +} +\value{ +an EML-formatted R object +} +\description{ +edit.DOI forces changes to an existing DOI +} +\details{ +If a DOI already exists in the <alternateidentifier> tag (get.DOI() to check), this allows the user to over-write the existing DOI. WARNING: will cause loss of the system="https://doi.org" setting. So only use this if you really don't already have a DOI. +} diff --git a/man/eml_getNPS.Rd b/man/eml_getNPS.Rd new file mode 100644 index 0000000..fa654d6 --- /dev/null +++ b/man/eml_getNPS.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils.R +\name{eml_getNPS} +\alias{eml_getNPS} +\title{alias for eml_get} +\usage{ +eml_getNPS(...) +} +\arguments{ +\item{emlObject}{is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml").} + +\item{elment}{is the name of the element to be extracted. If multiple occurrences are found, will extract all.} +} +\description{ +alias for eml_get +} +\details{ +eml_getNPS serves as an alias for the EML function eml_get. This means the eml_get() function will be called using current local version of EML on the users's machine rather than whatever version was available when the package was built. +} diff --git a/man/eml_get_simpleNPS.Rd b/man/eml_get_simpleNPS.Rd new file mode 100644 index 0000000..ecf71d6 --- /dev/null +++ b/man/eml_get_simpleNPS.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils.R +\name{eml_get_simpleNPS} +\alias{eml_get_simpleNPS} +\title{alias for eml_get_simple} +\usage{ +eml_get_simpleNPS(...) +} +\arguments{ +\item{emlObject}{is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml").} + +\item{elment}{is the name of the element to be extracted. If multiple occurances are found, will extract all.} +} +\description{ +alias for eml_get_simple +} +\details{ +eml_get_simpleNPS serves as an alias for the arcticdatautils function eml_get_simple. This means the eml_get_simple() function will be called using current local version of arcticdatautils on the users's machine rather than whatever version was available when the package was built. +} diff --git a/man/get.CUI.Rd b/man/get.CUI.Rd new file mode 100644 index 0000000..f06209c --- /dev/null +++ b/man/get.CUI.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/getEMLfunctions.R +\name{get.CUI} +\alias{get.CUI} +\title{returns a CUI statement} +\usage{ +get.CUI(emlObject) +} +\arguments{ +\item{emlObject}{is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml").} +} +\value{ +a text string +} +\description{ +get.CUI returns an english-language translation of the CUI codes +} +\details{ +get.CUI accesses the contents of the Controlled Unclassified Information (CUI) tag, <CUI> and returns an appropriate string of english-language text based on the properties of the CUI code. If thee <CUI> tag is empty or does not exist, get.CUI alerts the user and suggests specifying CUI using the set.CUI() funciton. +} diff --git a/man/get.DOI.Rd b/man/get.DOI.Rd new file mode 100644 index 0000000..9da9f99 --- /dev/null +++ b/man/get.DOI.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/getEMLfunctions.R +\name{get.DOI} +\alias{get.DOI} +\title{returns the DOI} +\usage{ +get.DOI(emlObject) +} +\arguments{ +\item{emlObject}{is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml").} +} +\value{ +a text string +} +\description{ +returns a text string that is the DOI for the datapackage +} +\details{ +accesses the contents of the<alternateIdentifier> tag and does some text manipulation to return a string with the DOI including the URL and prefaced by 'doi: '. +} diff --git a/man/get.DRRdoi.Rd b/man/get.DRRdoi.Rd new file mode 100644 index 0000000..fea3f36 --- /dev/null +++ b/man/get.DRRdoi.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/getEMLfunctions.R +\name{get.DRRdoi} +\alias{get.DRRdoi} +\title{returns the DOI of the associated DRR} +\usage{ +get.DRRdoi(emlObject) +} +\arguments{ +\item{emlObject}{is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml").} +} +\value{ +a text string +} +\description{ +get.DRRdoi returns a text string with the associated Data Release Report (DRR)'s DOI. +} +\details{ +get.DRRdoi accesses the <useageCitation> tag(s) and searches for the string "DRR: https://doi.org/". If that string is found, the contenst of that tag are returned. If the <useageCitation> tag is empty or not present, the user is informed and pointed to the set.DRRdoi() function to add the DOI of an associated DRR. +} diff --git a/man/get.DSRefID.Rd b/man/get.DSRefID.Rd new file mode 100644 index 0000000..27e7003 --- /dev/null +++ b/man/get.DSRefID.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/getEMLfunctions.R +\name{get.DSRefID} +\alias{get.DSRefID} +\title{returns the DataStore Reference ID} +\usage{ +get.DSRefID(emlObject) +} +\arguments{ +\item{emlObject}{is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml").} +} +\value{ +a text string +} +\description{ +get.DSRefID returns the DataStore Reference ID as a string of text. +} +\details{ +accesses the DOI listed in the <alternateIdentifier> tag and trims to to the last 7 digits, which should be identical to the DataStore Reference ID. If the <alternateIdentifier> tag is empty, it notifies the user that there is no DOI associate with the metadata and suggests adding one using set.DOI() (edit.DOI() would also work). +} diff --git a/man/get.abstract.Rd b/man/get.abstract.Rd new file mode 100644 index 0000000..742718a --- /dev/null +++ b/man/get.abstract.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/getEMLfunctions.R +\name{get.abstract} +\alias{get.abstract} +\title{returns the abstract} +\usage{ +get.abstract(emlObject) +} +\arguments{ +\item{emlObject}{is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml").} +} +\value{ +a text string +} +\description{ +returns the text from the <abstract> tag. +} +\details{ +returns the text from the <abstract> tag and attempts to clean up common text issues, such as enforcing UTF-8 formatting, getting rid of carriage returns, new lines, <para> and <literalLayout> tags and mucks about with layout, line breaks, etc. IF you see characters you don't like in the abstract, make sure to edit your abstract in a text editor (e.g. Notepad and NOT a Word). You should save the text to a new object and view it using writeLines() +} diff --git a/man/get.authorList.Rd b/man/get.authorList.Rd new file mode 100644 index 0000000..9b072fa --- /dev/null +++ b/man/get.authorList.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/getEMLfunctions.R +\name{get.authorList} +\alias{get.authorList} +\title{returns the authors} +\usage{ +get.authorList(emlObject) +} +\value{ +a text string +} +\description{ +get.authorList returns a text string with all of the authors listed under the <creator> tag. +} +\details{ +get.authorList assumes every author has at least 1 first name (either <givenName> or <givenName1>) and only one last name (<surName>). Middle names (<givenName2>) are optional. The author List is formatted with the last name, comma, first name for the first author and the fist name, last name for all subsequent authors. The last author's name is preceeded by an 'and'. + +#' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml"). +} diff --git a/man/get.beginDate.Rd b/man/get.beginDate.Rd new file mode 100644 index 0000000..605a9db --- /dev/null +++ b/man/get.beginDate.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/getEMLfunctions.R +\name{get.beginDate} +\alias{get.beginDate} +\title{returns the first date} +\usage{ +get.beginDate(emlObject) +} +\arguments{ +\item{emlObject}{is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml").} +} +\value{ +a text string +} +\description{ +get.beginDate returns the date of the earliest data point in the datapackage +} +\details{ +returns the date from the <beginDate> tag. Although dates should be formatted according to ISO-8601 (YYYY-MM-DD) it will also check for a few other common formats and return the date as a text string: "DD Month YYYY" +} +\examples{ +get.beginDate(emlObject) +} diff --git a/man/get.citation.Rd b/man/get.citation.Rd new file mode 100644 index 0000000..e819725 --- /dev/null +++ b/man/get.citation.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/getEMLfunctions.R +\name{get.citation} +\alias{get.citation} +\title{returns the datapackage citation} +\usage{ +get.citation(emlObject) +} +\value{ +a text string +} +\description{ +returns a Chicago manual of style citation for the datapackage +} +\details{ +allows the user to preview the what the citation will look like. The Harper's Ferry Style Guide recommends using the Chicago Manual of Style for formatting citations. The citation is formatted according to to a modified version of the Chicago Manual of Style's Author-Date journal article format because currently there is no Chicago Manual of Style format specified for datasets or datapackages. In compliance wiht DataCite's recommendations regarding including DOIs in citations, the citation displays the entire DOI as https://www.doi.org/10.58370/xxxxxx". + +#' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml"). +} diff --git a/man/get.endDate.Rd b/man/get.endDate.Rd new file mode 100644 index 0000000..7d05159 --- /dev/null +++ b/man/get.endDate.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/getEMLfunctions.R +\name{get.endDate} +\alias{get.endDate} +\title{returns the last date} +\usage{ +get.endDate(emlObject) +} +\value{ +a text sting +} +\description{ +get.endDate returns the date of the last data point in the datapackage +} +\details{ +returns the date from the <endDate> tag. Although dates should be formatted accoriding to ISO-8601 (YYYY-MM-DD) it will also check a few other common formats and return the date as a text string: "DD Month YYYY" + +#' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml"). +} +\examples{ +get.endDate(emlObject) +} diff --git a/man/get.fileInfo.Rd b/man/get.fileInfo.Rd new file mode 100644 index 0000000..fd0d936 --- /dev/null +++ b/man/get.fileInfo.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/getEMLfunctions.R +\name{get.fileInfo} +\alias{get.fileInfo} +\title{displays file names, sizes, and descriptions} +\usage{ +get.fileInfo(emlObject) +} +\arguments{ +\item{emlObject}{is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml").} +} +\value{ +a text string +} +\description{ +returns a plain-text table containing file names, file sizes, and short descriptions of the files. +} +\details{ +returns the file names (listed in the <objectName> tag), the size of the files (listed in the <size> tag) and converts it from bytes (B) to a more easily interpretable unit (KB, MB, GB, etc). Technically this uses powers of 2^10 so that KB is actually a kibibyte (1024 bytes) and not a kilobyte (1000 bytes). Similarly MB is a mebibyte not a megabyte, GB is a gibibyte not a gigabyte, etc. But for most practical purposes this is probably irrelevant. Finally, a short description is provided for each file (from the <entityDescription> tag). +} diff --git a/man/get.parkUnits.Rd b/man/get.parkUnits.Rd new file mode 100644 index 0000000..0380dfc --- /dev/null +++ b/man/get.parkUnits.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/getEMLfunctions.R +\name{get.parkUnits} +\alias{get.parkUnits} +\title{returns the park unit connections} +\usage{ +get.parkUnits(emlObject) +} +\arguments{ +\item{emlObject}{is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml").} +} +\value{ +a text string +} +\description{ +returns a string with the park unit codes where the data were collected +} +\details{ +accesses the contents of the <geographicDescription> tags and returns the contents of the tag that containst the text "NPS Unit Connections". If there is no <geographicDescription>, it alerts the user and suggests adding park unit connections using the set.parkUnits() function. +} diff --git a/man/get.title.Rd b/man/get.title.Rd new file mode 100644 index 0000000..5be48d1 --- /dev/null +++ b/man/get.title.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/getEMLfunctions.R +\name{get.title} +\alias{get.title} +\title{returns the datapackage title} +\usage{ +get.title(emlObject) +} +\value{ +a text string +} +\description{ +returns a text string that is the title of the datapackage +} +\details{ +accesses all of the <title> tags (there can be several, if each file was given a separate title). Assumes that the first instance of <title> referes to the entire datapackage and returns it as a text string, ignoring the contents of all other <title> tags. + +#' @param emlObject is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml"). +} diff --git a/man/set.CUI.Rd b/man/set.CUI.Rd new file mode 100644 index 0000000..bc4bcf1 --- /dev/null +++ b/man/set.CUI.Rd @@ -0,0 +1,31 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/editEMLfunctions.R +\name{set.CUI} +\alias{set.CUI} +\title{Adds CUI to metadata} +\usage{ +set.CUI(emlObject, CUI) +} +\arguments{ +\item{emlObject}{is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml").} + +\item{CUI}{a string consisting of one of 5 potential CUI codes. Pay attention to the spaces: +FED ONLY - Contains CUI. Only federal employees should have access (similar to "internal only" in DataStore) +FEDCON - Contains CUI. Only federal employees and federal contractors should have access (also very much like current "internal only" setting in DataStore) +DL ONLY - Contains CUI. Should only be available to a names list of individuals (where and how to list those individuals TBD) +NOCON - Contains CUI. Federal, state, local, or tribal employees may have access, but contractors cannot. +PUBVER - Does NOT contain CUI. The original data contained CUI, but in this datapackage CUI have been obscured so that it no longer contains CUI. +PUBFUL - Does NOT contain CUI. The original data contained no CUI. No data were obscured or altered to generate the data package} +} +\value{ +an EML-formatted R object +} +\description{ +set.CUI adds CUI codes to EML metadata +} +\details{ +set.CUI adds a CUI code to the tag <CUI> under <additionalMetadata><metadata>. +} +\examples{ +set.CUI(emlObject, "PUBFUL") +} diff --git a/man/set.DOI.Rd b/man/set.DOI.Rd new file mode 100644 index 0000000..d6c67a4 --- /dev/null +++ b/man/set.DOI.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/editEMLfunctions.R +\name{set.DOI} +\alias{set.DOI} +\title{Check & set a DOI} +\usage{ +set.DOI(emlObject, DOI) +} +\arguments{ +\item{emlObject}{is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml").} + +\item{DOI}{is the same as the 7-digit reference code generated on DataStore when a draft reference is initiated. Don't worry about the https://wwww.doi.org and the datapackage prefix - those will all automatically be added in by the function.} +} +\value{ +an EML-formatted R object +} +\description{ +Check & set a DOI +} +\details{ +This function checks to see if there is a DOI in the <alternateIdentifier> tag. The EMLassemblyline package stores datapackage DOIs in this tag (although the official EML schema has the DOI in a different location). If there is no DOI in the <alternateIdentifier> tag, the function adds a DOI. If there is a DOI, the function alerts the users to this fact, reports the existing DOI, and suggests using a separate function to edit an existing DOI (edit.DOI()). +} diff --git a/man/set.DRRdoi.Rd b/man/set.DRRdoi.Rd new file mode 100644 index 0000000..fd3a3ad --- /dev/null +++ b/man/set.DRRdoi.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/editEMLfunctions.R +\name{set.DRRdoi} +\alias{set.DRRdoi} +\title{adds DRR connection} +\usage{ +set.DRRdoi(emlObject, DRRrefID) +} +\arguments{ +\item{emlObject}{is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml").} + +\item{DRRrefID}{a 7-digit string that is the DataStore Reference ID for the DRR associated with the datapackage.} +} +\value{ +an EML-formatted R object +} +\description{ +set.DRRdoi adds the DOI of an associated DRR +} +\details{ +adds uses the DataStore Reference ID for an associate DRR to the <useageCitation> as a properly formatted DOI (prefaced with "DRR: ") to the <useageCitation> tag. ####CAUTION: in the current implimentation this may overwrite any other useageCitation info. +} +\examples{ +set.DRRdoi(emlObject, "2293234") +} diff --git a/man/set.parkUnits.Rd b/man/set.parkUnits.Rd new file mode 100644 index 0000000..2e7a40d --- /dev/null +++ b/man/set.parkUnits.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/editEMLfunctions.R +\name{set.parkUnits} +\alias{set.parkUnits} +\title{Adds Park Unit Connections to metadata} +\usage{ +set.parkUnits(emlObject, ParkUnits) +} +\arguments{ +\item{emlObject}{is an R object imported (typically from an EML-formatted .xml file) using EmL::read_eml(<filename>, from="xml").} + +\item{ParkUnits}{a string of comma-separated park unit codes} +} +\value{ +an EML-formatted R object +} +\description{ +Adds Park Unit Connections to metadata +} +\details{ +Add the Park Unit Connection(s) to a <geographicDescription> tag under <coverage>. Park Unit Connection(s) are the (typically) four-letter codes describing the park unit(s) where data were collected (e.g. ROMO, not ROMN). If there are already =items listed under geographicCoverage, Park Unit Connections will be inserted as the first item in the list of geographicCoverages and will be prefaced by the string "NPS Unit Connections:". +} +\examples{ +ParkUnits<-("ROMO, GRSD, TRYME") +set.parkUnits(emlObject, ParkUnits) +}