diff --git a/R/browse_metadata.R b/R/browse_metadata.R index 98068e13..bce7b850 100644 --- a/R/browse_metadata.R +++ b/R/browse_metadata.R @@ -16,7 +16,7 @@ #' for this dataset. Open the two html output files in your browser and use #' these as reference when running the map_metadata function. #' @examples -#' # Demo run +#' # Demo run requires no function inputs or user interaction #' browse_metadata() #' @export #' @importFrom dplyr %>% add_row diff --git a/R/map_metadata.R b/R/map_metadata.R index 1487a101..5b6cf8ed 100755 --- a/R/map_metadata.R +++ b/R/map_metadata.R @@ -36,7 +36,7 @@ #' mappings and 'LOG_' which contains details about the dataset and session. #' @examples #' \dontrun{ -#' # Demo run - requires user interactions +#' # Demo run requires no function inputs but requires user interaction #' map_metadata() #' } #' @export diff --git a/R/map_metadata_compare.R b/R/map_metadata_compare.R index feb5ab3a..7da2d621 100644 --- a/R/map_metadata_compare.R +++ b/R/map_metadata_compare.R @@ -5,7 +5,7 @@ #' #' @param session_dir This directory should contain 2 csv files for each session (LOG_ and OUTPUT_), 4 csv files in total. #' @param session1_base Base file name for session 1 e.g. 'NationalCommunityChildHealthDatabase(NCCHD)_BLOOD_TEST_2024-07-05-16-07-38' -#' @param session2_base Base file name for session 1 e.g. 'NationalCommunityChildHealthDatabase(NCCHD)_BLOOD_TEST_2024-07-08-12-03-30' +#' @param session2_base Base file name for session 2 e.g. 'NationalCommunityChildHealthDatabase(NCCHD)_BLOOD_TEST_2024-07-08-12-03-30' #' @param json_file The full path to the metadata file used when running map_metadata (should be the same for session 1 and session 2) #' @param domain_file The full path to the domain file used when running map_metadata (should be the same for session 1 and session 2) #' @return It returns a csv output, which represents the consensus decisions between session 1 and session 2 @@ -13,7 +13,24 @@ #' @importFrom utils read.csv write.csv #' @importFrom jsonlite fromJSON #' @importFrom cli cli_alert_success - +#' @examples +#' \dontrun{ +#' # Locate file paths for the example files in the package +#' demo_session_dir <- system.file("outputs", package = "browseMetadata") +#' demo_session1_base <- "NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-19-55" +#' demo_session2_base <- "NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-23-52" +#' demo_json_file <- system.file("inputs", "national_community_child_health_database_(ncchd)_20240405T130125.json", package = "browseMetadata") +#' demo_domain_file <- system.file("inputs", "domain_list_demo.csv", package = "browseMetadata") +#' +#' # Run the function - requires user interaction +#' map_metadata_compare( +#' session_dir = demo_session_dir, +#' session1_base = demo_session1_base, +#' session2_base = demo_session2_base, +#' json_file = demo_json_file, +#' domain_file = demo_domain_file +#' ) +#' } map_metadata_compare <- function(session_dir, session1_base, session2_base, json_file, domain_file) { timestamp_now_fname <- format(Sys.time(), "%Y-%m-%d-%H-%M-%S") @@ -110,7 +127,7 @@ map_metadata_compare <- function(session_dir, session1_base, session2_base, json table_find <- data.frame(table_n = numeric(length(dataset$childDataClasses)), table_label = character(length(dataset$childDataClasses))) for (t in 1:length(dataset$childDataClasses)) { table_find$table_n[t] <- t - table_find$table_label[t] <- dataset$childDataClasses[[t]]$label + table_find$table_label[t] <- dataset$childDataClasses$label[t] } table_n <- table_find$table_n[table_find$table_label == csv_1a$table[1]] diff --git a/R/map_metadata_convert.R b/R/map_metadata_convert.R index 2618e182..a79ccf75 100644 --- a/R/map_metadata_convert.R +++ b/R/map_metadata_convert.R @@ -8,7 +8,13 @@ #' @return The function will return 'L-OUTPUT_' in the same output_dir #' @export #' @importFrom utils read.csv write.csv - +#' @examples +#' # Locate file path and file name for the example files in the package +#' demo_output_dir <- system.file("outputs", package = "browseMetadata") +#' demo_output_csv <- "OUTPUT_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-19-55.csv" +#' +#' # Run the function +#' map_metadata_convert(output_csv = demo_output_csv, output_dir = demo_output_dir) map_metadata_convert <- function(output_csv, output_dir) { output <- read.csv(paste0(output_dir, "/", output_csv)) output_long <- output[0, ] # make duplicate diff --git a/codemeta.json b/codemeta.json index 3b4ad1d0..327329e0 100644 --- a/codemeta.json +++ b/codemeta.json @@ -226,7 +226,7 @@ }, "SystemRequirements": null }, - "fileSize": "753.382KB", + "fileSize": "1085.556KB", "citation": [ { "@type": "SoftwareSourceCode", diff --git a/inst/outputs/LOG_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-19-55.csv b/inst/outputs/LOG_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-19-55.csv new file mode 100644 index 00000000..218b1672 --- /dev/null +++ b/inst/outputs/LOG_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-19-55.csv @@ -0,0 +1,2 @@ +"timestamp","browseMetadata","initials","metadata_version","metadata_last_updated","domain_list_desc","dataset","table","table_note" +"2024-11-27 14:19:55",2.0.1,"demo","16.0.0","2024-03-14T17:40:57.463Z","DemoList","National Community Child Health Database (NCCHD)","CHILD","demo run" diff --git a/inst/outputs/LOG_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-23-52.csv b/inst/outputs/LOG_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-23-52.csv new file mode 100644 index 00000000..4f48cc7e --- /dev/null +++ b/inst/outputs/LOG_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-23-52.csv @@ -0,0 +1,2 @@ +"timestamp","browseMetadata","initials","metadata_version","metadata_last_updated","domain_list_desc","dataset","table","table_note" +"2024-11-27 14:23:52",2.0.1,"demo2","16.0.0","2024-03-14T17:40:57.463Z","DemoList","National Community Child Health Database (NCCHD)","CHILD","demo2" diff --git a/inst/outputs/OUTPUT_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-19-55.csv b/inst/outputs/OUTPUT_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-19-55.csv new file mode 100644 index 00000000..b8887ab0 --- /dev/null +++ b/inst/outputs/OUTPUT_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-19-55.csv @@ -0,0 +1,21 @@ +"timestamp","table","data_element_n","data_element","domain_code","note" +"2024-11-27 14:19:55","CHILD","1 of 35","ALF_E","2","AUTO CATEGORISED" +"2024-11-27 14:19:55","CHILD","2 of 35","ALF_MTCH_PCT","2","AUTO CATEGORISED" +"2024-11-27 14:19:55","CHILD","3 of 35","ALF_STS_CD","2","AUTO CATEGORISED" +"2024-11-27 14:19:55","CHILD","4 of 35","APGAR_1","7","" +"2024-11-27 14:19:55","CHILD","5 of 35","APGAR_2","7","" +"2024-11-27 14:19:55","CHILD","6 of 35","AVAIL_FROM_DT","1","AUTO CATEGORISED" +"2024-11-27 14:19:55","CHILD","7 of 35","BIRTH_ORDER","7","10% missingess" +"2024-11-27 14:19:55","CHILD","8 of 35","BIRTH_TM","1,7","20% missingess" +"2024-11-27 14:19:55","CHILD","9 of 35","BIRTH_WEIGHT","7","" +"2024-11-27 14:19:55","CHILD","10 of 35","BIRTH_WEIGHT_DEC","7","" +"2024-11-27 14:19:55","CHILD","11 of 35","BREASTFEED_8_WKS_FLG","7","" +"2024-11-27 14:19:55","CHILD","12 of 35","BREASTFEED_BIRTH_FLG","7","" +"2024-11-27 14:19:55","CHILD","13 of 35","CHILD_ID_E","2","" +"2024-11-27 14:19:55","CHILD","14 of 35","CURR_LHB_CD_BIRTH","5,7","Place of birth" +"2024-11-27 14:19:55","CHILD","15 of 35","DEL_CD","7","" +"2024-11-27 14:19:55","CHILD","16 of 35","DOD","3,7","" +"2024-11-27 14:19:55","CHILD","17 of 35","ETHNIC_GRP_CD","3","" +"2024-11-27 14:19:55","CHILD","18 of 35","GEST_AGE","3,7","" +"2024-11-27 14:19:55","CHILD","19 of 35","GNDR_CD","3","AUTO CATEGORISED" +"2024-11-27 14:19:55","CHILD","20 of 35","HEALTH_VISITOR_CD_E","2","" diff --git a/inst/outputs/OUTPUT_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-23-52.csv b/inst/outputs/OUTPUT_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-23-52.csv new file mode 100644 index 00000000..a4e7d4eb --- /dev/null +++ b/inst/outputs/OUTPUT_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-23-52.csv @@ -0,0 +1,21 @@ +"timestamp","table","data_element_n","data_element","domain_code","note" +"2024-11-27 14:23:52","CHILD","1 of 35","ALF_E","2","AUTO CATEGORISED" +"2024-11-27 14:23:52","CHILD","2 of 35","ALF_MTCH_PCT","2","AUTO CATEGORISED" +"2024-11-27 14:23:52","CHILD","3 of 35","ALF_STS_CD","2","AUTO CATEGORISED" +"2024-11-27 14:23:52","CHILD","4 of 35","APGAR_1","7","" +"2024-11-27 14:23:52","CHILD","5 of 35","APGAR_2","7","" +"2024-11-27 14:23:52","CHILD","6 of 35","AVAIL_FROM_DT","1","AUTO CATEGORISED" +"2024-11-27 14:23:52","CHILD","7 of 35","BIRTH_ORDER","1,7","" +"2024-11-27 14:23:52","CHILD","8 of 35","BIRTH_TM","7","" +"2024-11-27 14:23:52","CHILD","9 of 35","BIRTH_WEIGHT","7","" +"2024-11-27 14:23:52","CHILD","10 of 35","BIRTH_WEIGHT_DEC","7","" +"2024-11-27 14:23:52","CHILD","11 of 35","BREASTFEED_8_WKS_FLG","7","" +"2024-11-27 14:23:52","CHILD","12 of 35","BREASTFEED_BIRTH_FLG","7","" +"2024-11-27 14:23:52","CHILD","13 of 35","CHILD_ID_E","2","" +"2024-11-27 14:23:52","CHILD","14 of 35","CURR_LHB_CD_BIRTH","5,7","" +"2024-11-27 14:23:52","CHILD","15 of 35","DEL_CD","7","" +"2024-11-27 14:23:52","CHILD","16 of 35","DOD","3","" +"2024-11-27 14:23:52","CHILD","17 of 35","ETHNIC_GRP_CD","3","" +"2024-11-27 14:23:52","CHILD","18 of 35","GEST_AGE","7","" +"2024-11-27 14:23:52","CHILD","19 of 35","GNDR_CD","3","AUTO CATEGORISED" +"2024-11-27 14:23:52","CHILD","20 of 35","HEALTH_VISITOR_CD_E","0,1","" diff --git a/inst/outputs/PLOT_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-19-55.png b/inst/outputs/PLOT_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-19-55.png new file mode 100644 index 00000000..e7650093 Binary files /dev/null and b/inst/outputs/PLOT_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-19-55.png differ diff --git a/inst/outputs/PLOT_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-23-52.png b/inst/outputs/PLOT_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-23-52.png new file mode 100644 index 00000000..764d3e15 Binary files /dev/null and b/inst/outputs/PLOT_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-23-52.png differ diff --git a/man/browse_metadata.Rd b/man/browse_metadata.Rd index 7c2d7530..c5c78e85 100644 --- a/man/browse_metadata.Rd +++ b/man/browse_metadata.Rd @@ -29,6 +29,6 @@ these variables have a missing description. The third is a csv file storing the data that created this bar chart. \cr \cr } \examples{ -# Demo run +# Demo run requires no function inputs or user interaction browse_metadata() } diff --git a/man/map_metadata.Rd b/man/map_metadata.Rd index a6336e29..06d1d55b 100644 --- a/man/map_metadata.Rd +++ b/man/map_metadata.Rd @@ -58,7 +58,7 @@ function in a demo mode. } \examples{ \dontrun{ -# Demo run - requires user interactions +# Demo run requires no function inputs but requires user interaction map_metadata() } } diff --git a/man/map_metadata_compare.Rd b/man/map_metadata_compare.Rd index 69d8809a..8210f452 100644 --- a/man/map_metadata_compare.Rd +++ b/man/map_metadata_compare.Rd @@ -17,7 +17,7 @@ map_metadata_compare( \item{session1_base}{Base file name for session 1 e.g. 'NationalCommunityChildHealthDatabase(NCCHD)_BLOOD_TEST_2024-07-05-16-07-38'} -\item{session2_base}{Base file name for session 1 e.g. 'NationalCommunityChildHealthDatabase(NCCHD)_BLOOD_TEST_2024-07-08-12-03-30'} +\item{session2_base}{Base file name for session 2 e.g. 'NationalCommunityChildHealthDatabase(NCCHD)_BLOOD_TEST_2024-07-08-12-03-30'} \item{json_file}{The full path to the metadata file used when running map_metadata (should be the same for session 1 and session 2)} @@ -30,3 +30,22 @@ It returns a csv output, which represents the consensus decisions between sessio This function is to be used after running the map_metadata function. \cr \cr It compares csv outputs from two sessions, finds their differences, and asks for a consensus. \cr \cr } +\examples{ +\dontrun{ +# Locate file paths for the example files in the package +demo_session_dir <- system.file("outputs", package = "browseMetadata") +demo_session1_base <- "NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-19-55" +demo_session2_base <- "NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-23-52" +demo_json_file <- system.file("inputs", "national_community_child_health_database_(ncchd)_20240405T130125.json", package = "browseMetadata") +demo_domain_file <- system.file("inputs", "domain_list_demo.csv", package = "browseMetadata") + +# Run the function - requires user interaction +map_metadata_compare( + session_dir = demo_session_dir, + session1_base = demo_session1_base, + session2_base = demo_session2_base, + json_file = demo_json_file, + domain_file = demo_domain_file +) +} +} diff --git a/man/map_metadata_convert.Rd b/man/map_metadata_convert.Rd index 8fa55a98..bbf8afe0 100644 --- a/man/map_metadata_convert.Rd +++ b/man/map_metadata_convert.Rd @@ -19,3 +19,11 @@ The 'OUTPUT_' file groups multiple categorisations onto one line e.g. Domain_cod This function creates a new longer output 'L-OUTPUT_' which gives each categorisation its own row. \cr \cr This 'L-OUTPUT_' may be more useful when using these csv files in later analyses. } +\examples{ +# Locate file path and file name for the example files in the package +demo_output_dir <- system.file("outputs", package = "browseMetadata") +demo_output_csv <- "OUTPUT_NationalCommunityChildHealthDatabase(NCCHD)_CHILD_2024-11-27-14-19-55.csv" + +# Run the function +map_metadata_convert(output_csv = demo_output_csv, output_dir = demo_output_dir) +}