Skip to content

Commit

Permalink
moved remove variable to radio buttons in data quality tab and allow …
Browse files Browse the repository at this point in the history
…users to select one or more variable to remove from dataset (#95)
  • Loading branch information
Paul-Carvalho authored May 29, 2024
1 parent 3cae844 commit 6bbfe96
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 36 deletions.
43 changes: 25 additions & 18 deletions inst/ShinyFiles/MainApp/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -2473,17 +2473,21 @@ server = function(input, output, session) {
'poisson', 'negative binomial'), selected='normal'))
})

output$remove_vars <- renderUI({
tagList(selectInput('varsToRemove', 'Select variables to remove', choices = names(values$dataset), multiple = TRUE))

})

#Lat/Lon
output$LatLonDir <- renderUI({
tagList(
conditionalPanel(condition="input.checks=='Lat_Lon units'",
selectizeInput('LatDirection','Latitudinal variable',
choices=c('None', find_lat(values$dataset)),
options = list(create = TRUE, placeholder='Select or type variable name')),

selectizeInput('LonDirection','Longitudinal variable',
choices=c('None', find_lon(values$dataset)),
options = list(create = TRUE, placeholder='Select or type variable name')))
selectizeInput('LatDirection','Latitudinal variable',
choices=c('None', find_lat(values$dataset)),
options = list(create = TRUE, placeholder='Select or type variable name')),

selectizeInput('LonDirection','Longitudinal variable',
choices=c('None', find_lon(values$dataset)),
options = list(create = TRUE, placeholder='Select or type variable name'))
)
})

Expand Down Expand Up @@ -2535,11 +2539,12 @@ server = function(input, output, session) {
} else if(input$checks=='NaNs'){
nan_filter(values$dataset, project = project$name, x=qaqc_helper(values$dataset, "NaN", "names"),
replace = FALSE, remove = FALSE, rep.value=NA, over_write=FALSE)
} else if (input$checks=='Remove variables'){
h4("Select variables to remove from the dataset")
} else if(input$checks=='Unique observations'){
unique_filter(values$dataset, project = project$name, remove=FALSE)
} else if(input$checks=='Empty variables'){
empty_vars_filter(values$dataset, project = project$name, remove=FALSE)

} else if(input$checks=='Lat_Lon units'){
degree(values$dataset, project = project$name, lat=NULL, lon=NULL, latsign=NULL, lonsign=NULL, replace=FALSE)
} else {
Expand Down Expand Up @@ -3133,6 +3138,16 @@ server = function(input, output, session) {
}
})

observeEvent(input$removeVars,{
if(!is_value_empty(input$varsToRemove != "")){
values$dataset <- subset(values$dataset, select = -which(names(values$dataset) %in% input$varsToRemove))
showNotification(paste0("Variable(s) ", paste(input$varsToRemove, collapse = ", "), " removed from dataset."), type = "message")
} else {
showNotification("No variables selected.", type = "warning")
}

})

observeEvent(input$Outlier_Filter, {

q_test <- quietly_test(outlier_remove)
Expand Down Expand Up @@ -3563,8 +3578,7 @@ server = function(input, output, session) {
}
})

observeEvent(c(input$subsetData,
input$output_table_exploration_search_columns), {
observeEvent(input$output_table_exploration_search_columns, {
# cell edited?
if (input$SelectDatasetExplore == "main") {
values$dataset <- explore_temp()
Expand Down Expand Up @@ -3660,16 +3674,9 @@ server = function(input, output, session) {
#values$dataset <- temp
})


observeEvent(input$subsetData,{
req(!is.null(input$output_table_exploration_columns_selected))
values$dataset <- values$dataset[,-(input$output_table_exploration_columns_selected+1)]
})

output$editText <- renderText('Edit cells: double click. Edited table will not be loaded into \nworking environment until saved.
\nFilter: Boxes at top.
\nFilter functions saved to FishSET database as FilterTable \nwhen "save data" button is pushed.
\nRemove variables: Click on column cell(s), then click "Remove \nVariable" button. Variables can be added back using \nthe add_vars function.
\nClick the "Save Data" button to save changes.')

#Subset by columns
Expand Down
32 changes: 14 additions & 18 deletions inst/ShinyFiles/MainApp/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -359,20 +359,14 @@ ui = function(request){

radioButtons("checks", "Select data quality check function to run:",
choices = c('Variable class', 'Summary table', 'Outliers',
'NAs', 'NaNs', 'Unique observations', 'Empty variables',
'Latitude and Longitude'='Lat_Lon units', 'Spatial data')),
'NAs', 'NaNs', 'Remove variables', 'Unique observations',
'Empty variables', 'Latitude and Longitude'='Lat_Lon units',
'Spatial data')),

conditionalPanel(
condition = "input.checks == 'Variable class'",

conditionalPanel(condition = "input.checks == 'Variable class'",
uiOutput('change_var_inputs'),

actionButton('rchclass', 'Change variable classes', class = "btn-secondary")
),
uiOutput('outlier_column'),
uiOutput('outlier_subset_method'),
uiOutput('outlier_subset'),
uiOutput('outlier_dist'),
conditionalPanel("input.checks == 'NAs'",
actionButton('NA_Filter_all', 'Remove all NAs',class = "btn-secondary"),
actionButton('NA_Filter_mean', 'Replace NAs with mean value', class = "btn-secondary")
Expand All @@ -381,6 +375,15 @@ ui = function(request){
actionButton('NAN_Filter_all', 'Remove all NaNs', class = "btn-secondary"),
actionButton('NAN_Filter_mean', 'Replace NaNs with mean value', class = "btn-secondary")
),
conditionalPanel("input.checks == 'Remove variables'",
uiOutput('remove_vars'),
actionButton("removeVars", "Remove variables", class = "btn-secondary")

),
uiOutput('outlier_column'),
uiOutput('outlier_subset_method'),
uiOutput('outlier_subset'),
uiOutput('outlier_dist'),
conditionalPanel("input.checks=='Outliers'",
actionButton('Outlier_Filter', 'Remove outliers', class = "btn-secondary"),
uiOutput("hover_info1")
Expand All @@ -391,9 +394,8 @@ ui = function(request){
conditionalPanel("input.checks=='Empty variables'",
actionButton('Empty_Filter', 'Remove empty variables', class = "btn-secondary")
),
uiOutput('LatLonDir'),

conditionalPanel("input.checks=='Lat_Lon units'",
uiOutput('LatLonDir'),
selectInput('LatLon_Filter_Lat', 'Change sign for latitude direction',
choices=c('None', 'All values'='all', 'Positve to negative'='neg',
'Negative to positive'='pos'), selected='None'),
Expand Down Expand Up @@ -507,19 +509,13 @@ ui = function(request){
tabPlotUI("explore")

),
conditionalPanel("input.plot_table=='Table'",
actionButton('subsetData', 'Remove variable from dataset',
width = "100%",
class = "btn-primary")
),

actionButton("refresh", "Refresh data",
width = "100%",
class = "btn-primary"

),


conditionalPanel("input.SelectDatasetExplore=='main' || input.SelectDatasetExplore=='grid'",
selectInput('plot_table', 'View data table or plots',
choices=c('Table','Plots'), selected='Table')
Expand Down

0 comments on commit 6bbfe96

Please sign in to comment.