Skip to content

Commit

Permalink
Merge branch 'develop' into 494-epatada-continuous-data-flag-error
Browse files Browse the repository at this point in the history
  • Loading branch information
hillarymarler authored Jul 17, 2024
2 parents 785d161 + 1306599 commit e6dc512
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ readme.md
readme.html
.gitignore
^articles
^vignettes/articles$
17 changes: 14 additions & 3 deletions R/Figures.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions man/TADA_FieldValuesPie.Rd

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

2 changes: 2 additions & 0 deletions vignettes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.html
*.R
File renamed without changes.
File renamed without changes.

0 comments on commit e6dc512

Please sign in to comment.