Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Copyright: This software is in the public domain because it contains materials
that originally came from the U.S. Environmental Protection Agency.
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Imports:
plyr,
data.table,
Expand Down
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.