Skip to content

Commit

Permalink
filter field selection working
Browse files Browse the repository at this point in the history
  • Loading branch information
triphook committed Feb 23, 2024
1 parent fc79471 commit 3c076ef
Show file tree
Hide file tree
Showing 4 changed files with 14,616 additions and 18 deletions.
35 changes: 19 additions & 16 deletions R/mod_filtering.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
mod_filtering_ui <- function(id) {
ns <- NS(id)
tagList(
shiny::fluidRow(column(
6,
shiny::radioButtons(
ns("field_sel"),
label = "",
choices = c("key", "most", "all"),
selected = "key",
inline = TRUE
)
)),
htmltools::HTML("<h3>Select field to filter on:</h3>"),
htmltools::HTML(
"Key columns are listed in the table below, along with the number of unique values present in that field. These counts do not include unique values from results flagged for removal. Click on a field name and a new table will appear below showing the counts associated with each unique value in the selected field."
"Fields are listed in the table below, along with the number of unique values present in that field. These counts do not include unique values from results flagged for removal. Click on a field name and a new table will appear below showing the counts associated with each unique value in the selected field."
),
shiny::radioButtons(
ns("field_sel"),
label = "Fields to select from: ",
choices = c("key", "most", "all"),
selected = "key",
inline = TRUE
),
DT::dataTableOutput(ns("filterStep1")),
htmltools::br(),
Expand Down Expand Up @@ -179,9 +176,16 @@ mod_filtering_server <- function(id, tadat) {
}
})

shiny::observeEvent(input$field_sel, {
tadat$field_sel <- input$field_sel
})

shiny::observeEvent(tadat$field_sel, {
shiny::updateRadioButtons(session, "field_sel", selected = tadat$field_sel)
if (!is.null(tables$dat)) {
tables$filter_fields <-
TADA::TADA_FieldCounts(tables$dat, display = tadat$field_sel)
}
})

# reset all filters in bottom table
Expand Down Expand Up @@ -302,13 +306,14 @@ mod_filtering_server <- function(id, tadat) {
tadat$removals[label] <- as.logical(results)
}
}

# Get counts for the filters
if (!is.null(tables$dat) & nrow(tadat$selected_filters > 0)) {
# Refresh the 'count' field
new_selected_filters <- tadat$selected_filters
new_selected_filters$Count <- NULL
new_selected_filters <- cbind(new_selected_filters, Count=0)
new_selected_filters <-
cbind(new_selected_filters, Count = 0)
for (i in 1:nrow(new_selected_filters)) {
row = new_selected_filters[i, ]
values = getValues(tables$dat, row$Field)
Expand All @@ -319,7 +324,7 @@ mod_filtering_server <- function(id, tadat) {
}
})


getValues <- function(.data, field) {
counts <- table(.data[[field]], useNA = "ifany")
if (length(rownames(counts) > 0)) {
Expand All @@ -332,5 +337,3 @@ mod_filtering_server <- function(id, tadat) {
}
})
}


1 change: 0 additions & 1 deletion R/utils_flag_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ applyFlags <- function(in_table, orgs) {

# Invalid result unit
out <- TADA::TADA_FlagResultUnit(out, clean = "none")
print(paste0("Step 5: ", nrow(out)))

# QC rep/blank
out <- TADA::TADA_FindQCActivities(out, clean = FALSE)
Expand Down
5 changes: 4 additions & 1 deletion R/utils_track_progress.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ writeFile <- function(tadat, filename) {
od_method <- tadat$od_method
nd_mult <- tadat$nd_mult
od_mult <- tadat$od_mult
field_sel <- tadat$field_sel

save(
original_source,
Expand All @@ -48,6 +49,7 @@ writeFile <- function(tadat, filename) {
od_method,
nd_mult,
od_mult,
field_sel,
file = filename
)

Expand Down Expand Up @@ -94,7 +96,8 @@ readFile <- function(tadat, filename) {
tadat$nd_method = nd_method
tadat$od_method = od_method
tadat$nd_mult = nd_mult
tadat$od_mult
tadat$od_mult = od_mult
tadat$field_sel = field_sel
}


Expand Down
Loading

0 comments on commit 3c076ef

Please sign in to comment.