Skip to content
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

Hotfix/expand frictionless md #50

Merged
merged 3 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: ohcleandat
Type: Package
Title: One Health Data Cleaning and Quality Checking Package
Version: 0.3.6
Version: 0.3.7
Authors@R: c(
person("Collin", "Schwantes", email = "[email protected]", role = c("cre", "aut"), comment = c(ORCID = "0000-0003-4014-4896")),
person("Johana", "Teigen", email = "[email protected]", role = "aut", comment = c(ORCID = "0000-0002-6209-2321")),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# ohcleandat 0.3.7

* Fixing bug in expand metadata - function now allows for updates

# ohcleandat 0.3.6

* Adds a function to update the descriptive metadata in a frictionless datapackage
Expand Down
8 changes: 5 additions & 3 deletions R/expand_frictionless_metadata.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Expand Frictionless Metadata with structural metadata
#'
#' Loops over elements in the structural metadata and adds them to frictionless
#' metadata schema.
#' metadata schema. Will overwrite existing values.
#'
#' @param structural_metadata Dataframe. Structural metadata from
#' `create_structural_metadata` or `update_structural_metadata`
Expand Down Expand Up @@ -66,13 +66,15 @@ expand_frictionless_metadata <- function(structural_metadata,
y <- structural_metadata[idx,idy][[1]]
# get property name
property_to_add_name <- names(structural_metadata)[idy]
property_to_add_value <- y

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

property_to_add_value <- y

names(property_to_add_value) <- property_to_add_name
x <- c(x, property_to_add_value)
}
Expand Down
2 changes: 1 addition & 1 deletion man/expand_frictionless_metadata.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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,38,"Collin","b",1
2024-08-27,64,"Johana","a",2
2024-08-28,94,"Johana","e",3
2024-08-29,75,"Johana","a",4
2024-08-30,49,"Collin","d",5
2024-08-31,78,"Collin","d",6
2024-09-01,93,"Johana","b",7
2024-09-02,2,"Johana","c",8
2024-09-03,91,"Johana","c",9
2024-09-04,27,"Johana","a",10
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
6 changes: 6 additions & 0 deletions vignettes/metadata.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ 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

descriptive_metadata <- list (
Expand All @@ -194,6 +198,8 @@ descriptive_metadata <- list (
creator = list (list (name = "A. Person"), list (name = "B. Person"),list (name = "C. Person"),list (name = "F. Person"))
# , accessRights = "open"
)


update_frictionless_metadata(descriptive_metadata = descriptive_metadata,
data_package_path = "data_examples/datapackage.json"
)
Expand Down