From 032bb1b1296d7d56ab727216bbd86d3d21e3bf38 Mon Sep 17 00:00:00 2001 From: RayStick <50215726+RayStick@users.noreply.github.com> Date: Mon, 6 Jan 2025 11:03:17 +0000 Subject: [PATCH] add dataset title to BAR plot --- R/metadata_map.R | 3 ++- R/plotting.R | 6 +++--- README.md | 2 +- codemeta.json | 2 +- ...unityChildHealthDatabase(NCCHD)_2024-12-19-14-11-55.html | 6 +++--- man/empty_plot.Rd | 4 ++-- vignettes/mapmetadata.Rmd | 2 +- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/R/metadata_map.R b/R/metadata_map.R index c465cb5..69d20f3 100755 --- a/R/metadata_map.R +++ b/R/metadata_map.R @@ -86,7 +86,8 @@ metadata_map <- function( empty_count_df <- empty_count(dataset) ## Use 'empty_plot.R' to create bar plot then save it - barplot_html <- empty_plot(empty_count_df, n_tables) + bar_title <- paste0("\n'", dataset_name, "' contains ", n_tables, " table(s)") + barplot_html <- empty_plot(empty_count_df, bar_title) original_wd <- getwd() setwd(output_dir) # saveWidget has a bug with paths & saving base_fname <- paste0( diff --git a/R/plotting.R b/R/plotting.R index 815ebc0..67a9c3e 100644 --- a/R/plotting.R +++ b/R/plotting.R @@ -3,12 +3,12 @@ #' This function is called within the metadata_map function. \cr \cr #' It plots \cr \cr #' @param dataframe Dataframe to plot. Output of empty_count.R function. -#' @param n_tables The number of table names in this dataframe. +#' @param bar_title Title for the plot. #' @return A plotly object #' @keywords internal #' @importFrom plotly plot_ly layout -empty_plot <- function(dataframe, n_tables) { +empty_plot <- function(dataframe, bar_title) { barplot_html <- plot_ly(dataframe, x = ~Table, y = ~N_Variables, @@ -22,7 +22,7 @@ empty_plot <- function(dataframe, n_tables) { ) %>% layout( barmode = "stack", - title = paste0("\n", "Dataset contains ", n_tables, " table(s)"), + title = bar_title, xaxis = list(title = "Table"), yaxis = list(title = "Variable Count"), legend = list(title = list(text = "Empty Description")) diff --git a/README.md b/README.md index d34a991..0cff508 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Press 'Esc' key to finish here, or press any other key to continue with mapping Stopping here just gets you the summary plot, which is saved to your project directory. All outputs from this `metadata_map` function are saved to your project directory. You can change the save location by adjusting the `output_dir` argument. - + If you continue, the function will ask you to pick a table in the dataset. In demo mode, the function processes only the first 20 variables from the selected table. Follow the on-screen instructions, and categorise variables into research domains, using the Plot tab as your reference. The demo will simplify domains for ease of use; in a real scenario, you can define more specific domains. For more tips on these mapping steps, see the [mapmetadata tutorial](https://aim-rsf.github.io/mapmetadata/articles/mapmetadata.html) page on the package website. diff --git a/codemeta.json b/codemeta.json index 577fc8e..8c9b2c3 100644 --- a/codemeta.json +++ b/codemeta.json @@ -226,7 +226,7 @@ }, "SystemRequirements": null }, - "fileSize": "6141.312KB", + "fileSize": "6164.024KB", "citation": [ { "@type": "SoftwareSourceCode", diff --git a/inst/outputs/BAR_360_NationalCommunityChildHealthDatabase(NCCHD)_2024-12-19-14-11-55.html b/inst/outputs/BAR_360_NationalCommunityChildHealthDatabase(NCCHD)_2024-12-19-14-11-55.html index cd3659a..a61bec2 100644 --- a/inst/outputs/BAR_360_NationalCommunityChildHealthDatabase(NCCHD)_2024-12-19-14-11-55.html +++ b/inst/outputs/BAR_360_NationalCommunityChildHealthDatabase(NCCHD)_2024-12-19-14-11-55.html @@ -1953,9 +1953,9 @@