From 94a36002b2d7cadf968f7b8187a7eeec37374b68 Mon Sep 17 00:00:00 2001 From: Collin Schwantes Date: Mon, 9 Dec 2024 14:25:51 -0500 Subject: [PATCH] adding a debugging scripts folder --- scripts/debug_expand_df.R | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 scripts/debug_expand_df.R diff --git a/scripts/debug_expand_df.R b/scripts/debug_expand_df.R new file mode 100644 index 0000000..a6e63df --- /dev/null +++ b/scripts/debug_expand_df.R @@ -0,0 +1,46 @@ +devtools::load_all() + + +# read in data + + + +df <- read.csv("vignettes/data_examples/my_data.csv") + +# create codebook + +structural_metadata <- create_structural_metadata(df,primary_key = "key", + foreign_key = c("measured_by","site_name")) + +# create data package + + +dp <- frictionless::create_package() |> + frictionless::add_resource(resource_name = "my_data", + data = df) + +frictionless::write_package(package = dp, + directory = "vignettes/data_examples") + +expand_frictionless_metadata(structural_metadata = structural_metadata, + resource_name = "my_data", + resource_path = "vignettes/data_examples/my_data.csv", + data_package_path = "vignettes/data_examples/datapackage.json" + ) + +## drop a measured_by column + +df <- read.csv("vignettes/data_examples/my_data.csv") + +# create codebook + +structural_metadata_2 <- create_structural_metadata(df, + primary_key = "key", + foreign_key = c("site_name")) + + +expand_frictionless_metadata(structural_metadata = structural_metadata_2, + resource_name = "my_data", + resource_path = "vignettes/data_examples/my_data.csv", + data_package_path = "vignettes/data_examples/datapackage.json" +)