From 3e49868ff4e765a0742b07bd9982ddbabd52297e Mon Sep 17 00:00:00 2001 From: Andreas Gammelgaard Damsbo Date: Thu, 3 Apr 2025 06:31:05 +0200 Subject: [PATCH] ui on modify pane --- R/app_version.R | 2 +- R/helpers.R | 2 +- R/update-variables-ext.R | 4 +- inst/apps/FreesearchR/app.R | 143 +++++++----------- .../shinyapps.io/agdamsbo/freesearcheR.dcf | 2 +- inst/apps/FreesearchR/ui.R | 135 ++++++----------- 6 files changed, 109 insertions(+), 179 deletions(-) diff --git a/R/app_version.R b/R/app_version.R index 78dde90..e266f7b 100644 --- a/R/app_version.R +++ b/R/app_version.R @@ -1 +1 @@ -app_version <- function()'250402_1131' +app_version <- function()'250403_0630' diff --git a/R/helpers.R b/R/helpers.R index f09528b..a78ad78 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -335,7 +335,7 @@ data_description <- function(data) { p_complete <- n_complete/n sprintf( - i18n("Data has %s observations and %s variables, with %s (%s%%) complete cases"), + i18n("Data has %s observations and %s variables, with %s (%s%%) complete cases."), n, n_var, n_complete, diff --git a/R/update-variables-ext.R b/R/update-variables-ext.R index 7f48480..8699330 100644 --- a/R/update-variables-ext.R +++ b/R/update-variables-ext.R @@ -118,8 +118,8 @@ update_variables_server <- function(id, output$data_info <- shiny::renderUI({ shiny::req(data_r()) - data <- data_r() - sprintf(i18n("Data has %s observations and %s variables."), nrow(data), ncol(data)) + data_description(data_r()) + # sprintf(i18n("Data has %s observations and %s variables."), nrow(data), ncol(data)) }) variables_r <- shiny::reactive({ diff --git a/inst/apps/FreesearchR/app.R b/inst/apps/FreesearchR/app.R index aa2fc12..f9735d7 100644 --- a/inst/apps/FreesearchR/app.R +++ b/inst/apps/FreesearchR/app.R @@ -10,7 +10,7 @@ #### Current file: /Users/au301842/FreesearchR/R//app_version.R ######## -app_version <- function()'250402_1131' +app_version <- function()'250403_0630' ######## @@ -2808,7 +2808,7 @@ data_description <- function(data) { p_complete <- n_complete/n sprintf( - i18n("Data has %s observations and %s variables, with %s (%s%%) complete cases"), + i18n("Data has %s observations and %s variables, with %s (%s%%) complete cases."), n, n_var, n_complete, @@ -6911,8 +6911,8 @@ update_variables_server <- function(id, output$data_info <- shiny::renderUI({ shiny::req(data_r()) - data <- data_r() - sprintf(i18n("Data has %s observations and %s variables."), nrow(data), ncol(data)) + data_description(data_r()) + # sprintf(i18n("Data has %s observations and %s variables."), nrow(data), ncol(data)) }) variables_r <- shiny::reactive({ @@ -7952,90 +7952,47 @@ ui_elements <- list( fluidRow( shiny::column( width = 9, - shiny::tags$p(shiny::markdown("Below, are several options to update variables (rename, set new labels (for nicer tables in the report) and change variable classes (numeric, factor/categorical etc.).), modify factor/categorical variables as well as create new factor from a continous variable or new variables with *R* code.")) + shiny::tags$p(shiny::markdown("Below, are several options for simple data manipulation like update variables by renaming, creating new labels (for nicer tables in the report) and changing variable classes (numeric, factor/categorical etc.)."), + shiny::tags$p("There are also more advanced options to modify factor/categorical variables as well as create new factor from a continous variable or new variables with *R* code. At the bottom you can restore the original data.")) ) ), - shiny::tags$br(), - shiny::tags$br(), + # shiny::tags$br(), update_variables_ui("modal_variables"), shiny::tags$br(), shiny::tags$br(), - fluidRow( + tags$h4("Advanced data manipulation"), + shiny::tags$br(), + shiny::tags$br(), + shiny::fluidRow( shiny::column( - width = 2 - ), - shiny::column( - width = 8, - tags$h4("Advanced data manipulation"), + width = 4, + shiny::actionButton( + inputId = "modal_update", + label = "Reorder factor levels", + width = "100%" + ), shiny::tags$br(), - fluidRow( - shiny::column( - width = 6, - # tags$h4("Update or modify variables"), - # shiny::tags$br(), - # shiny::actionButton( - # inputId = "modal_variables", - # label = "Subset, rename and change class/type", - # width = "100%" - # ), - # shiny::tags$br(), - # shiny::helpText("Subset variables, rename variables and labels, and apply new class to variables"), - # shiny::tags$br(), - # shiny::tags$br(), - shiny::actionButton( - inputId = "modal_update", - label = "Reorder factor levels", - width = "100%" - ), - shiny::tags$br(), - shiny::helpText("Reorder the levels of factor/categorical variables."), - shiny::tags$br(), - shiny::tags$br(), - shiny::actionButton( - inputId = "data_reset", - label = "Restore original data", - width = "100%" - ), - shiny::tags$br(), - shiny::helpText("Reset to original imported dataset. Careful! There is no un-doing."), - shiny::tags$br(), - shiny::tags$br() - ), - shiny::column( - width = 6, - # tags$h4("Create new variables"), - # shiny::tags$br(), - shiny::actionButton( - inputId = "modal_cut", - label = "New factor", - width = "100%" - ), - shiny::tags$br(), - shiny::helpText("Create factor/categorical variable from a continous variable (number/date/time)."), - shiny::tags$br(), - shiny::tags$br(), - shiny::actionButton( - inputId = "modal_column", - label = "New variable", - width = "100%" - ), - shiny::tags$br(), - shiny::helpText(shiny::markdown("Create a new variable/column based on an *R*-expression.")), - shiny::tags$br(), - shiny::tags$br() - ) - ) # , - # tags$h4("Restore"), - # shiny::actionButton( - # inputId = "data_reset", - # label = "Restore original data", - # width = "100%" - # ), - # shiny::tags$br(), - # shiny::helpText("Reset to original imported dataset. Careful! There is no un-doing.") + shiny::helpText("Reorder the levels of factor/categorical variables."), ), shiny::column( - width = 2 + width = 4, + shiny::actionButton( + inputId = "modal_cut", + label = "New factor", + width = "100%" + ), + shiny::tags$br(), + shiny::helpText("Create factor/categorical variable from a continous variable (number/date/time).") + ), + shiny::column( + width = 4, + shiny::actionButton( + inputId = "modal_column", + label = "New variable", + width = "100%" + ), + shiny::tags$br(), + shiny::helpText(shiny::markdown("Create a new variable/column based on an *R*-expression.")) ) ), shiny::tags$br(), @@ -8043,24 +8000,32 @@ ui_elements <- list( tags$h4("Compare modified data to original"), shiny::tags$br(), shiny::tags$p( - "Here is a overview of the original vs the modified data." + "Raw print of the original vs the modified data." ), shiny::tags$br(), - shiny::tags$br(), - fluidRow( - column( + shiny::fluidRow( + shiny::column( width = 6, - tags$b("Original data:"), + shiny::tags$b("Original data:"), # verbatimTextOutput("original"), - verbatimTextOutput("original_str") + shiny::verbatimTextOutput("original_str") ), - column( + shiny::column( width = 6, - tags$b("Modified data:"), + shiny::tags$b("Modified data:"), # verbatimTextOutput("modified"), - verbatimTextOutput("modified_str") + shiny::verbatimTextOutput("modified_str") ) - ) + ), + shiny::tags$br(), + shiny::actionButton( + inputId = "data_reset", + label = "Restore original data", + width = "100%" + ), + shiny::tags$br(), + shiny::helpText("Reset to original imported dataset. Careful! There is no un-doing."), + shiny::tags$br() ) ) ), diff --git a/inst/apps/FreesearchR/rsconnect/shinyapps.io/agdamsbo/freesearcheR.dcf b/inst/apps/FreesearchR/rsconnect/shinyapps.io/agdamsbo/freesearcheR.dcf index b4bce6b..b93efe5 100644 --- a/inst/apps/FreesearchR/rsconnect/shinyapps.io/agdamsbo/freesearcheR.dcf +++ b/inst/apps/FreesearchR/rsconnect/shinyapps.io/agdamsbo/freesearcheR.dcf @@ -5,6 +5,6 @@ account: agdamsbo server: shinyapps.io hostUrl: https://api.shinyapps.io/v1 appId: 13611288 -bundleId: 10042980 +bundleId: 10047791 url: https://agdamsbo.shinyapps.io/freesearcheR/ version: 1 diff --git a/inst/apps/FreesearchR/ui.R b/inst/apps/FreesearchR/ui.R index 81c0fa8..063438d 100644 --- a/inst/apps/FreesearchR/ui.R +++ b/inst/apps/FreesearchR/ui.R @@ -180,90 +180,47 @@ ui_elements <- list( fluidRow( shiny::column( width = 9, - shiny::tags$p(shiny::markdown("Below, are several options to update variables (rename, set new labels (for nicer tables in the report) and change variable classes (numeric, factor/categorical etc.).), modify factor/categorical variables as well as create new factor from a continous variable or new variables with *R* code.")) + shiny::tags$p(shiny::markdown("Below, are several options for simple data manipulation like update variables by renaming, creating new labels (for nicer tables in the report) and changing variable classes (numeric, factor/categorical etc.)."), + shiny::tags$p("There are also more advanced options to modify factor/categorical variables as well as create new factor from a continous variable or new variables with *R* code. At the bottom you can restore the original data.")) ) ), - shiny::tags$br(), - shiny::tags$br(), + # shiny::tags$br(), update_variables_ui("modal_variables"), shiny::tags$br(), shiny::tags$br(), - fluidRow( + tags$h4("Advanced data manipulation"), + shiny::tags$br(), + shiny::tags$br(), + shiny::fluidRow( shiny::column( - width = 2 - ), - shiny::column( - width = 8, - tags$h4("Advanced data manipulation"), + width = 4, + shiny::actionButton( + inputId = "modal_update", + label = "Reorder factor levels", + width = "100%" + ), shiny::tags$br(), - fluidRow( - shiny::column( - width = 6, - # tags$h4("Update or modify variables"), - # shiny::tags$br(), - # shiny::actionButton( - # inputId = "modal_variables", - # label = "Subset, rename and change class/type", - # width = "100%" - # ), - # shiny::tags$br(), - # shiny::helpText("Subset variables, rename variables and labels, and apply new class to variables"), - # shiny::tags$br(), - # shiny::tags$br(), - shiny::actionButton( - inputId = "modal_update", - label = "Reorder factor levels", - width = "100%" - ), - shiny::tags$br(), - shiny::helpText("Reorder the levels of factor/categorical variables."), - shiny::tags$br(), - shiny::tags$br(), - shiny::actionButton( - inputId = "data_reset", - label = "Restore original data", - width = "100%" - ), - shiny::tags$br(), - shiny::helpText("Reset to original imported dataset. Careful! There is no un-doing."), - shiny::tags$br(), - shiny::tags$br() - ), - shiny::column( - width = 6, - # tags$h4("Create new variables"), - # shiny::tags$br(), - shiny::actionButton( - inputId = "modal_cut", - label = "New factor", - width = "100%" - ), - shiny::tags$br(), - shiny::helpText("Create factor/categorical variable from a continous variable (number/date/time)."), - shiny::tags$br(), - shiny::tags$br(), - shiny::actionButton( - inputId = "modal_column", - label = "New variable", - width = "100%" - ), - shiny::tags$br(), - shiny::helpText(shiny::markdown("Create a new variable/column based on an *R*-expression.")), - shiny::tags$br(), - shiny::tags$br() - ) - ) # , - # tags$h4("Restore"), - # shiny::actionButton( - # inputId = "data_reset", - # label = "Restore original data", - # width = "100%" - # ), - # shiny::tags$br(), - # shiny::helpText("Reset to original imported dataset. Careful! There is no un-doing.") + shiny::helpText("Reorder the levels of factor/categorical variables."), ), shiny::column( - width = 2 + width = 4, + shiny::actionButton( + inputId = "modal_cut", + label = "New factor", + width = "100%" + ), + shiny::tags$br(), + shiny::helpText("Create factor/categorical variable from a continous variable (number/date/time).") + ), + shiny::column( + width = 4, + shiny::actionButton( + inputId = "modal_column", + label = "New variable", + width = "100%" + ), + shiny::tags$br(), + shiny::helpText(shiny::markdown("Create a new variable/column based on an *R*-expression.")) ) ), shiny::tags$br(), @@ -271,24 +228,32 @@ ui_elements <- list( tags$h4("Compare modified data to original"), shiny::tags$br(), shiny::tags$p( - "Here is a overview of the original vs the modified data." + "Raw print of the original vs the modified data." ), shiny::tags$br(), - shiny::tags$br(), - fluidRow( - column( + shiny::fluidRow( + shiny::column( width = 6, - tags$b("Original data:"), + shiny::tags$b("Original data:"), # verbatimTextOutput("original"), - verbatimTextOutput("original_str") + shiny::verbatimTextOutput("original_str") ), - column( + shiny::column( width = 6, - tags$b("Modified data:"), + shiny::tags$b("Modified data:"), # verbatimTextOutput("modified"), - verbatimTextOutput("modified_str") + shiny::verbatimTextOutput("modified_str") ) - ) + ), + shiny::tags$br(), + shiny::actionButton( + inputId = "data_reset", + label = "Restore original data", + width = "100%" + ), + shiny::tags$br(), + shiny::helpText("Reset to original imported dataset. Careful! There is no un-doing."), + shiny::tags$br() ) ) ),