diff --git a/NAMESPACE b/NAMESPACE index 0e60b75..caa62e1 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -18,7 +18,6 @@ export(p99) export(pn) export(spada) export(suna) -import(data.table) import(shiny) importFrom(DescTools,Gmean) importFrom(DescTools,Hmean) @@ -50,8 +49,19 @@ importFrom(bslib,popover) importFrom(bslib,sidebar) importFrom(bslib,tooltip) importFrom(bslib,value_box) +importFrom(data.table,"%between%") +importFrom(data.table,"%notin%") +importFrom(data.table,":=") +importFrom(data.table,.SD) +importFrom(data.table,as.data.table) +importFrom(data.table,between) +importFrom(data.table,copy) importFrom(data.table,fcase) +importFrom(data.table,fread) +importFrom(data.table,fwrite) importFrom(data.table,setDT) +importFrom(data.table,setcolorder) +importFrom(data.table,setorderv) importFrom(dplyr,arrange) importFrom(dplyr,filter) importFrom(dplyr,mutate) diff --git a/NEWS.md b/NEWS.md index a35ad9b..fa0a953 100644 --- a/NEWS.md +++ b/NEWS.md @@ -14,13 +14,23 @@ editor_options: 3 - Functionalities to detect and treat duplicates -4 - Sample filters for datasets +4 - Functionalities to detect and treat outliers -5 - Functionalities to detect and treat outliers +5 - Inference: t test -6 - Inference: t test +6 - Models: linear model, logistic regression, Kmeans, Trees -7 - Models: linear model, logistic regression, Kmeans, Trees +## 2025.02.13-1 + +Highlights: Use of selectizeInput with close and clear button for multiple selections + +### Improvements + +1 - **Convert Cols, Descriptive Stats, Order Cols, Order Rows and Select Cols** modules: now usage of selectizeInput with close and clear button for multiple selections + +2 - **utils.R**: filter_rows function now with env = list(var1) in data.table instead of get(var) + +3 - **spada.R**: now usage of importFrom for data.table package ## 2025.02.11-1 diff --git a/R/convert_cols_module.R b/R/convert_cols_module.R index c92d40c..bf193d9 100644 --- a/R/convert_cols_module.R +++ b/R/convert_cols_module.R @@ -103,10 +103,11 @@ convert_cols_server <- function(id, input_df, input_df_trigger) { df$df_active[preview_sample(), ], select = input$vars_sel) preview_df_temp[ - , preview := convert(get(input$vars_sel), + , preview := convert(var1, type = input$sel_format, date_format = input$sel_date_formats, - date_origin = input$sel_date_origin)] + date_origin = input$sel_date_origin), + env = list(var1 = input$vars_sel)] }) output$preview_gt <- render_gt({ @@ -130,11 +131,13 @@ convert_cols_server <- function(id, input_df, input_df_trigger) { if(input$vars_sel == '' | input$sel_format == ''){ msg('Choose a variable and a new format') } else { + df$df_active[, input$vars_sel := - convert(get(input$vars_sel), + convert(var1, type = input$sel_format, date_format = input$sel_date_formats, - date_origin = input$sel_date_origin)] + date_origin = input$sel_date_origin), + env = list(var1 = input$vars_sel)] msg('Conversion applied') } diff --git a/R/descriptive_stats_module.R b/R/descriptive_stats_module.R index 818f048..87bfb1d 100644 --- a/R/descriptive_stats_module.R +++ b/R/descriptive_stats_module.R @@ -56,8 +56,11 @@ descriptive_stats_server <- function(id, df) { output$parameters <- renderUI({ tagList( - selectInput(ns('sel_var'), 'Variables', var_analysis(), - var_analysis()[1], multiple = T), + selectizeInput( + ns('sel_var'), 'Variables', var_analysis(), var_analysis()[1], + multiple = T, + options = list(plugins = list('remove_button', 'clear_button')) + ), ) }) diff --git a/R/order_cols_module.R b/R/order_cols_module.R index f74c7cd..d0e8612 100644 --- a/R/order_cols_module.R +++ b/R/order_cols_module.R @@ -34,7 +34,10 @@ order_cols_server <- function(id, input_df) { }) output$ui_var_cols <- renderUI( - selectInput(ns('vars_cols'), 'Variables to move', c('', df_names()), multiple = T) + selectizeInput(ns('vars_cols'), 'Variables to move', c('', df_names()), + multiple = T, + options = list(plugins = list('remove_button', 'clear_button')) + ) ) # rest of vars to order diff --git a/R/order_rows_module.R b/R/order_rows_module.R index 3e6e428..2a29bb1 100644 --- a/R/order_rows_module.R +++ b/R/order_rows_module.R @@ -7,10 +7,12 @@ order_rows_ui <- function(id) { card_header('Order Rows', class = 'mini-header'), card_body( uiOutput(ns('ui_var_rows')), - selectInput(ns('vars_descending'), + selectizeInput(ns('vars_descending'), list('Vars in descending order', bs_icon('info-circle')) |> ttip('If not informed, the order will be Ascending', PLACE = 'right'), - '', multiple = T), + '', multiple = T, + options = list(plugins = list("remove_button", "clear_button")) + ), radioButtons(ns('radio_nas'), "NA's placement", c('Last' = 'last', 'First' = 'first'), inline = T), @@ -34,12 +36,14 @@ order_rows_server <- function(id, input_df) { }) output$ui_var_rows <- renderUI( - selectInput(ns('vars_rows'), 'Order by', c('', df_names()), multiple = T) + selectizeInput(ns('vars_rows'), 'Order by', c('', df_names()), multiple = T, + options = list(plugins = list('remove_button', 'clear_button')) + ) ) # vars in descending order observe({ - updateSelectInput( + updateSelectizeInput( session, 'vars_descending', label = 'Descending Order', diff --git a/R/select_cols_module.R b/R/select_cols_module.R index 546c64c..fd622c0 100644 --- a/R/select_cols_module.R +++ b/R/select_cols_module.R @@ -28,7 +28,9 @@ select_cols_server <- function(id, input_df) { }) output$ui_var_sel <- renderUI( - selectInput(ns('vars_sel'), 'Variable', c('', df_names()), multiple = T) + selectizeInput(ns('vars_sel'), 'Variable', c('', df_names()), multiple = T, + options = list(plugins = list('remove_button', 'clear_button')) + ) ) observe({ diff --git a/R/spada.R b/R/spada.R index 635545b..4a05a9f 100644 --- a/R/spada.R +++ b/R/spada.R @@ -9,7 +9,6 @@ #' #' @export #' -#' @import data.table #' @import shiny #' #' @importFrom bsicons bs_icon @@ -19,6 +18,9 @@ #' layout_sidebar nav_item nav_menu nav_panel nav_select nav_spacer #' navset_card_pill page_navbar popover sidebar tooltip value_box #' +#' @importFrom data.table %between% %notin% .SD := as.data.table between copy +#' fread fwrite setcolorder setDT setorderv + #' @importFrom DescTools Gmean Hmean Kurt Mode Outlier ShapiroFranciaTest #' Skew ZTest #' diff --git a/R/utils.R b/R/utils.R index 3b0450b..f5de1df 100644 --- a/R/utils.R +++ b/R/utils.R @@ -218,37 +218,37 @@ convert <- function(x, type, date_format = '%Y-%m-%d', # filter function ------------------------------------------------------------- filter_rows <- function(df, var, operator, filter_value){ if(operator == '=='){ - df[get(var) == filter_value, ] + df[var1 == filter_value, , env = list(var1 = var)] } else if(operator == '!='){ - df[get(var) != filter_value, ] + df[var1 != filter_value, , env = list(var1 = var)] } else if(operator == '>'){ - df[get(var) > filter_value, ] + df[var1 > filter_value, , env = list(var1 = var) ] } else if(operator == '>='){ - df[get(var) >= filter_value, ] + df[var1 >= filter_value, , env = list(var1 = var) ] } else if(operator == '<'){ - df[get(var) < filter_value, ] + df[var1 < filter_value, , env = list(var1 = var) ] } else if(operator == '<='){ - df[get(var) <= filter_value, ] + df[var1 <= filter_value, , env = list(var1 = var) ] } else if(operator == 'is_na'){ - df[is.na(get(var)), ] + df[is.na(var1), , env = list(var1 = var) ] } else if(operator == 'not_na'){ - df[!is.na(get(var)), ] + df[!is.na(var1), , env = list(var1 = var) ] } else if(operator == 'in'){ - df[get(var) %in% filter_value, ] + df[var1 %in% filter_value, , env = list(var1 = var)] } else if(operator == 'not_in'){ - df[!get(var) %in% filter_value, ] + df[!var1 %in% filter_value, , env = list(var1 = var) ] } else if(operator == 'between'){ - df[get(var) %between% filter_value, ] + df[var1 %between% filter_value, , env = list(var1 = var) ] } else if(operator == 'not_between'){ - df[!(get(var) %between% filter_value), ] + df[!(var1 %between% filter_value), , env = list(var1 = var) ] } else if(operator == 'outlier'){ - df[Outlier(get(var), value = F, na.rm = T), ] + df[Outlier(var1, value = F, na.rm = T), , env = list(var1 = var)] } else if(operator == 'not_outlier'){ - df[!Outlier(get(var), value = F, na.rm = T), ] + df[!Outlier(var1, value = F, na.rm = T), , env = list(var1 = var)] } else if(operator == 'is_true'){ - df[get(var) == TRUE, ] + df[var1 == TRUE, , env = list(var1 = var)] } else if(operator == 'is_false'){ - df[get(var) == FALSE, ] + df[var1 == FALSE, , env = list(var1 = var)] } } diff --git a/R/zzz.R b/R/zzz.R index 645e861..d3061cb 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -18,6 +18,8 @@ utils::globalVariables( 'x', 'values', 'results', - 'value' + 'value', + 'var1', + 'measure' ) ) diff --git a/docs/news/index.html b/docs/news/index.html index fe12b19..15edf85 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -64,16 +64,25 @@
Highlights: Use of selectizeInput with close and clear button for multiple selections
+1 - Convert Cols, Descriptive Stats, Order Cols, Order Rows and Select Cols modules: now usage of selectizeInput with close and clear button for multiple selections
+2 - utils.R: filter_rows function now with env = list(var1) in data.table instead of get(var)
+3 - spada.R: now usage of importFrom for data.table package
+Highlights: New filter options in Filter Rows Module
1 - Filter Rows module: new options to filter: compare two variables and sample
2 - Config Page module: Inicial hex color now in caps
3 - utils.R: new function filter_rows_2vars for compare two variables and col_type
@@ -87,7 +96,7 @@1 - Descriptive Stats module: added geometric mean, harmonic mean, skewness and kurtosis from DescTools package.
2 - Normality test module: new test, Shapiro-Francia from DescTools package.
3 - Exploratory module: bug fix in scatter. (#18)
@@ -101,7 +110,7 @@1 - Import file module: now csv has a number of lines to read parameter and can read sav (SPSS) files
2 - Z Test module: now has a plot with test results
3 - utils.R: plot_z_test function
@@ -116,7 +125,7 @@1 - navbar_df_info and sidebar modules: now number of rows with 1 decimal value (function f_num) for better look (solve side effect after use of nsmall in previous release)
2 - New Rename Cols module: new module for rename variables of active dataset
Only visual and formatting changes.
1 - Convert Cols, Data Overview and Sidebar modules: background color receive object bg_color
2 - Correlation, Normality Test and Z Test modules: sidebars color now with bg_color object and stati_card with blue color
3 - Descriptive Stats module: gain digits input and f_num for format values
@@ -142,7 +151,7 @@1 - Correlation module: chane name of Alternatives and chance card header title to Correlation Test
2 - Export file module: now writes Sav (haven package) and uses checkbox to compress RDS
3 - Normality Test module: better names and better checks for Shapiro-Wilk Test (#15)
@@ -156,7 +165,7 @@1 - Correlation module: now check if Standard Deviation of any informed variable is zero, avoiding warning. Also fixed (#14).
2 - Exploratory module: now with req (for main variable and variable 2) in render_plot (output$gt_dist)
3 - Stats table module: align columns, use ‘-’ for sub_missing becasue the long dash is not an ASCII and could not be replicated in sub_values (devtools::check). Also fixed (#13)
@@ -184,7 +193,7 @@1 - Descriptive Stats module: now Mode returns NA (not as character) and only paste/collapse values if Mode exists. Inserted sub_missing() in gt_stats for better look and consistency with other views
2 - Stats table module: now Mode returns NA (not as character) and only paste/collapse values if Mode exists
3 - Exploratory module: now the Variable 2 can not be float in Boxplot by Groups, because does not seam reasonable to have an infinite number of groups. Related to (#11)
@@ -197,7 +206,7 @@1 - New dependencie: package DescTools
2 - Descriptive Stats module: now with Mode (DescTools package) for numeri, character and factor variables
3 - Filter Rows module: refactored to check operators and values. New operators: Outlier (and Not Outlier) and Logical (TRUE and FALSE)
@@ -208,7 +217,7 @@1 - Correlation module: parameters in card sidebar for better use of space
2 - df_info function: new test file and now returns empty data.frame (accepted by gt_info) in case of no columns in the entry data.frame
3 - Normality test module: now Ks and Shapiro-wilk tests have gt table, save button and statiCards
@@ -218,7 +227,7 @@1 - Correlation module: new layout, new table with test results, help button (help documentation), save table button and statiCards (shnywidgets) with Correlation and p value.
2 - Descriptive Stats module: now with variable selected by default
3 - Normality test module: new Help button in Ks test and Shapiro-Wilk test
@@ -229,7 +238,7 @@1 - Startup page: now with startup page with shinybusy package (new dependencie)
2 - radioGroupButtons: change some radioButtons (shiny) for radioGroupButtons (shinyWidgets) in data_overview_module and exploratory_module for better look
3 - Page config module: colorPickr now with ‘save’ mode for better reset of values and other visual changes fo better look
@@ -242,7 +251,7 @@1 - New module: Filter Rows
2 - Convert module: always align right the preview table
3 - Descriptive Stats module: now all options inicially as TRUE
@@ -257,7 +266,7 @@1 - New module: Normality test
2 - Module Correlation > Scatter Plot now has a button to render plot
3 - Module Descriptive Stats now has a button to render table
@@ -271,7 +280,7 @@1 - testthat: create structure to run tests (test-fina.R as initial test)
2 - New modules: Order Rows, Convert Cols and Exploratory
3 - Correlation module: insert req in scatter plot
@@ -286,7 +295,7 @@1 - New modules: Sidebar and Navbar Df Info
2 - New function filter_rows in utils.R
3 - New reactives: df_active_ncol, df_active_resume_data and df$df_trigger (to use for updates)
@@ -312,7 +321,7 @@1 - Stats table now is a module
2 - new module Correlation
3 - new module Descriptive Stats
@@ -330,7 +339,7 @@1 - utils functions
2 - page_config_module: correction of a typo
3 - spada function
@@ -346,7 +355,7 @@1 - export_file_module: separator order now semicolon as default
2 - new import_file_module: allows input csv and RDS files
3 - page_config_module: new visual and size of input file as parameter
@@ -370,7 +379,7 @@1 - utils functions
df_info now uses suna instead of length, this change fix errors and provide gain in speed.
deletion of format_color_bar and main_value_box functions given that they are now in use anymore
1 - General
Created zzz.R and inserted utils::globalVariables for global variables (check note)
Value boxes: resized to give more space for other elements
1 - utils functions
1 - New functionality: copy dataset (Data page)
2 - Config page now is a module
3 - New Some reactives now with bindCache
@@ -443,7 +452,7 @@1 - utils functions
change color in value boxes (to gray) for better looking
number of rows (value box) now with decimals
1 - utils functions
df_info: improvement in performance (something like half the time in big datasets - 1e6 rows)
new function: gt_info to generate metadata with gt package