Skip to content

Commit

Permalink
Merge pull request #51 from ecohealthalliance/hotfix/expand_frictionl…
Browse files Browse the repository at this point in the history
…ess_md

Hotfix/expand frictionless md
  • Loading branch information
collinschwantes authored Sep 5, 2024
2 parents 39086fb + 373929c commit c27e331
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
5 changes: 2 additions & 3 deletions R/expand_frictionless_metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,14 @@ expand_frictionless_metadata <- function(structural_metadata,
# get property name
property_to_add_name <- names(structural_metadata)[idy]
property_to_add_value <- y
names(property_to_add_value) <- property_to_add_name

# overwrite properties that already exist
if(property_to_add_name %in% names(x)){
x[property_to_add_name] <- property_to_add_value
next()
}


names(property_to_add_value) <- property_to_add_name
# add new property
x <- c(x, property_to_add_value)
}

Expand Down
20 changes: 10 additions & 10 deletions vignettes/data_examples/my_data.csv
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"date","measurement","measured_by","site_name","key"
2024-08-26,20,"Johana","b",1
2024-08-27,13,"Johana","c",2
2024-08-28,51,"Collin","b",3
2024-08-29,14,"Collin","b",4
2024-08-30,19,"Collin","c",5
2024-08-31,29,"Johana","d",6
2024-09-01,2,"Johana","d",7
2024-09-02,88,"Collin","a",8
2024-09-03,21,"Johana","d",9
2024-09-04,25,"Johana","c",10
2024-08-26,43,"Johana","c",1
2024-08-27,9,"Johana","c",2
2024-08-28,79,"Johana","c",3
2024-08-29,17,"Collin","a",4
2024-08-30,61,"Johana","e",5
2024-08-31,30,"Collin","b",6
2024-09-01,58,"Collin","a",7
2024-09-02,27,"Johana","d",8
2024-09-03,52,"Johana","d",9
2024-09-04,82,"Collin","e",10
12 changes: 9 additions & 3 deletions vignettes/metadata.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,6 @@ expand_frictionless_metadata(structural_metadata = structural_metadata,
data_package_path = "data_examples/datapackage.json")
# update the deposit the new structural metadata
cli$deposit_update()
## OOPs actually I need to add more to the description
Expand All @@ -209,6 +206,15 @@ cli$deposit_fill_metadata(descriptive_metadata)
# upload to zenodo - this creates a **draft** deposit in Zenodo
cli$deposit_upload_file(path = "data_examples/")
## update structural metadata
structural_metadata[1,2] <- "New description"
expand_frictionless_metadata(structural_metadata = structural_metadata,
resource_name = "my_data", # name of the file with no extension
resource_path = "data_examples/my_data.csv",
data_package_path = "data_examples/datapackage.json")
# there are methods for embargoing or restricting deposits in {deposits}
Expand Down

0 comments on commit c27e331

Please sign in to comment.