diff --git a/.Rbuildignore b/.Rbuildignore index 7c52877a..0b0fbfc0 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -8,3 +8,4 @@ readme.md readme.html .gitignore ^articles +^vignettes/articles$ diff --git a/R/Figures.R b/R/Figures.R index 7015fb2f..a6701dd6 100644 --- a/R/Figures.R +++ b/R/Figures.R @@ -666,15 +666,26 @@ TADA_FlaggedSitesMap <- function(.data) { #' # Create a list of parameters in the dataset and the number of records of #' # each parameter: #' TADA_FieldValuesPie(Data_Nutrients_UT, field = "TADA.CharacteristicName") +#' # If there are more than 12 categories to display, any remaining categories, the ones that have the smallest number of results, +#' # are combined into an "ALL OTHERS" category. +#' TADA_FieldValuesPie(Data_Nutrients_UT, field = "TADA.ComparableDataIdentifier") #' TADA_FieldValuesPie <- function(.data, field = "null", characteristicName = "null") { - dat <- TADA_FieldValuesTable(.data = .data, field = field, characteristicName = characteristicName) - + dat <- head(TADA_FieldValuesTable(.data = .data, field = field, characteristicName = characteristicName), 12) + # If data set contains more than 12 categories, dat2 aggregates 'all other' categories into its own row. + dat2 <- data.frame(Value = "ALL OTHERS", Count = sum(TADA_FieldValuesTable(.data = .data, field = field, characteristicName = characteristicName)[-(1:12),][2])) + dat$Legend <- paste0(dat$Value, " - ", dat$Count, " results") + dat2$Legend <- paste0(dat2$Value, " - ", dat2$Count, " results") dat <- dat %>% dplyr::rowwise() %>% dplyr::mutate(Legend = TADA_InsertBreaks(Legend)) - + + # Only apply the all others category if there are greater than 12 categories to display. + if(dat2$Count != 0) { + dat <- dplyr::bind_rows(dat, dat2) + } + # create TADA color palette tada.pal <- TADA_ColorPalette() diff --git a/man/TADA_FieldValuesPie.Rd b/man/TADA_FieldValuesPie.Rd index f731569a..355e4a9f 100644 --- a/man/TADA_FieldValuesPie.Rd +++ b/man/TADA_FieldValuesPie.Rd @@ -26,5 +26,8 @@ data(Data_Nutrients_UT) # Create a list of parameters in the dataset and the number of records of # each parameter: TADA_FieldValuesPie(Data_Nutrients_UT, field = "TADA.CharacteristicName") +# If there are more than 12 categories to display, any remaining categories, the ones that have the smallest number of results, +# are combined into an "ALL OTHERS" category. +TADA_FieldValuesPie(Data_Nutrients_UT, field = "TADA.ComparableDataIdentifier") } diff --git a/vignettes/.gitignore b/vignettes/.gitignore new file mode 100644 index 00000000..097b2416 --- /dev/null +++ b/vignettes/.gitignore @@ -0,0 +1,2 @@ +*.html +*.R diff --git a/articles/TADAAssessmentUnitUseCase.Rmd b/vignettes/articles/TADAAssessmentUnitUseCase.Rmd similarity index 100% rename from articles/TADAAssessmentUnitUseCase.Rmd rename to vignettes/articles/TADAAssessmentUnitUseCase.Rmd diff --git a/articles/TADAWaterSciConWorkshopDemo.Rmd b/vignettes/articles/TADAWaterSciConWorkshopDemo.Rmd similarity index 100% rename from articles/TADAWaterSciConWorkshopDemo.Rmd rename to vignettes/articles/TADAWaterSciConWorkshopDemo.Rmd