-
Notifications
You must be signed in to change notification settings - Fork 14
kelly code review #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
KellyWang1126
wants to merge
1
commit into
NCEAS:master
Choose a base branch
from
KellyWang1126:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| #ticket 20632 | ||
|
|
||
| library(arcticdatautils) | ||
| library(dataone) | ||
| library(EML) | ||
| library(dplyr) | ||
| library(datapack) | ||
| library(ncdf4) | ||
|
|
||
| rm <- "resource_map_urn:uuid:610b0253-5fa1-492b-a6af-abdd012ed325" | ||
| pkg <- get_package(adc, rm) | ||
| doc <- read_eml(getObject(adc, pkg$metadata)) | ||
|
|
||
| # abstract: a number of the borehole | ||
| doc$dataset$abstract <- gsub("\\(C43-MS1\\)", "borehole with number C43-MS1", doc$dataset$abstract) | ||
| doc$dataset$abstract <- gsub("45 km", "45 kilometers (km)", doc$dataset$abstract) | ||
| doc$dataset$abstract <- gsub("5.2 m", "5.2 meters (m)", doc$dataset$abstract) | ||
|
|
||
| # add decription of images | ||
| for (i in 2:length(doc$dataset$otherEntity)) { | ||
| doc$dataset$otherEntity[[i]]$entityDescription <- paste("Photographs of frozen cores for", substr(doc$dataset$otherEntity[[i]]$entityName, start = 30, stop = 40)) | ||
| } | ||
|
|
||
| # remove attribute for otherEntity | ||
| for (i in 1:length(doc$dataset$otherEntity)) { | ||
| doc$dataset$otherEntity[[i]]$attributeList <- NULL | ||
| } | ||
|
|
||
| # add physical | ||
| for (i in 1:length(doc$dataset$otherEntity)) { | ||
| id <- gsub("urn-uuid-", "urn:uuid:", doc$dataset$otherEntity[[i]]$id) | ||
| doc$dataset$otherEntity[[i]]$physical <- pid_to_eml_physical(adc, id) | ||
| } | ||
|
|
||
| # add creator info | ||
| doc$dataset$creator[[2]]$electronicMailAddress <- "ecoscience@alaska.net" | ||
| doc$dataset$creator[[2]]$userId$directory <- "https://orcid.org" | ||
| doc$dataset$creator[[2]]$userId$userId <- "https://orcid.org/0000-0002-9834-8851" | ||
|
|
||
| doc$dataset$creator[[3]]$electronicMailAddress <- "akliljedahl@alaska.edu" | ||
| doc$dataset$creator[[3]]$userId$directory <- "https://orcid.org" | ||
| doc$dataset$creator[[3]]$userId$userId <- "https://orcid.org/0000-0001-7114-6443" | ||
|
|
||
| doc$dataset$creator[[4]]$electronicMailAddress <- "ronald.daanen@alaska.gov" | ||
| doc$dataset$creator[[4]]$userId$directory <- "https://orcid.org" | ||
| doc$dataset$creator[[4]]$userId$userId <- "https://orcid.org/0000-0001-7511-1491" | ||
| doc$dataset$creator[[4]]$individualName$givenName <- "Ronald P." | ||
|
|
||
| # set contact = creator for MK | ||
| doc$dataset$contact <- doc$dataset$creator[[1]] | ||
| doc$dataset$contact$id <- NULL | ||
|
|
||
| # set nsf | ||
| awards <- c("1722572", "1820883") %>% unlist() | ||
| doc$dataset$project <- eml_nsf_to_project(awards) | ||
|
|
||
| # add FAIR | ||
| doc <- eml_add_publisher(doc) | ||
| doc <- eml_add_entity_system(doc) | ||
|
|
||
| # methods: expand acronym | ||
| doc$dataset$methods$methodStep$description$para <- gsub("cu. in.", "cubic inches", doc$dataset$methods$methodStep$description$para) | ||
| doc$dataset$methods$methodStep$description$para <- gsub("h.p.", "horsepower", doc$dataset$methods$methodStep$description$para) | ||
| doc$dataset$methods$methodStep$description$para <- gsub("72 h", "72 hours", doc$dataset$methods$methodStep$description$para) | ||
|
|
||
| # valid EML | ||
| eml_validate(doc) | ||
|
|
||
| # write EML | ||
| eml_path <- "/home/kwang/MikhailK_JagoRiver/metadata.xml" | ||
| write_eml(doc, eml_path) | ||
|
|
||
| # update EML | ||
| #update <- publish_update(adc, | ||
| # metadata_pid = pkg$metadata, | ||
| # resource_map_pid = pkg$resource_map, | ||
| # data_pids = pkg$data, | ||
| # metadata_path = eml_path, | ||
| # public = FALSE) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! everything looks very similar to how I would achieve these tasks |
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't know you could use this to achieve this! I usually use the web editor or
str_replacebut this is a good way too!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when I know both I get confused between
gsubandstr_replacebecause the two has the order of the arguments in slightly different positions (pattern first or string first)