From 144e1f2c3fe31972d3e4647165de45b4fbbd4758 Mon Sep 17 00:00:00 2001 From: lilyclements Date: Thu, 14 Nov 2024 13:33:10 +0000 Subject: [PATCH 1/5] Fixing sort for descending --- instat/static/InstatObject/R/data_object_R6.R | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index 05d230eb34..394c50eff4 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -1567,19 +1567,10 @@ DataSheet$set("public", "sort_dataframe", function(col_names = c(), decreasing = message("No sorting to be done.") } } else { - # Build the expressions using rlang for sorting columns - col_names_exp <- purrr::map(col_names, function(col_name) { - if (!(col_name %in% names(curr_data))) { - stop(col_name, " is not a column in the data.") - } - if (decreasing) dplyr::desc(rlang::sym(col_name)) else rlang::sym(col_name) - }) - - # Handle the case where sorting by row names and column names at the same time if (by_row_names) warning("Cannot sort by columns and row names. Sorting will be done by given columns only.") - - # Sort the data based on the expressions - self$set_data(dplyr::arrange(curr_data, !!!col_names_exp)) + + if (decreasing) self$set_data(dplyr::arrange(curr_data, dplyr::across(dplyr::all_of(col_names), desc))) + else self$set_data(dplyr::arrange(curr_data, dplyr::across(dplyr::all_of(col_names)))) } self$data_changed <- TRUE } From 0a1ad3243a0b8d1b4adc5bc4fd5b9c9b1b0431cb Mon Sep 17 00:00:00 2001 From: KWAMBAI VITALIS Date: Thu, 14 Nov 2024 17:27:17 +0300 Subject: [PATCH 2/5] changes to the code --- instat/dlgSummaryTables.Designer.vb | 15 --------------- instat/dlgSummaryTables.vb | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/instat/dlgSummaryTables.Designer.vb b/instat/dlgSummaryTables.Designer.vb index dc580406db..62161275db 100644 --- a/instat/dlgSummaryTables.Designer.vb +++ b/instat/dlgSummaryTables.Designer.vb @@ -55,7 +55,6 @@ Partial Class dlgSummaryTables Me.ucrPnlMargin = New instat.UcrPanel() Me.lblMarginName = New System.Windows.Forms.Label() Me.lblVariables = New System.Windows.Forms.Label() - Me.cmdFormatTable = New System.Windows.Forms.Button() Me.rdoFrequencyTable = New System.Windows.Forms.RadioButton() Me.rdoSummaryTable = New System.Windows.Forms.RadioButton() Me.grpPercentages = New System.Windows.Forms.GroupBox() @@ -297,18 +296,6 @@ Partial Class dlgSummaryTables Me.lblVariables.Tag = "" Me.lblVariables.Text = "Variables :" ' - 'cmdFormatTable - ' - Me.cmdFormatTable.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.cmdFormatTable.Location = New System.Drawing.Point(429, 696) - Me.cmdFormatTable.Margin = New System.Windows.Forms.Padding(4) - Me.cmdFormatTable.Name = "cmdFormatTable" - Me.cmdFormatTable.Size = New System.Drawing.Size(156, 34) - Me.cmdFormatTable.TabIndex = 19 - Me.cmdFormatTable.Text = "Format Table..." - Me.cmdFormatTable.UseVisualStyleBackColor = True - Me.cmdFormatTable.Visible = False - ' 'rdoFrequencyTable ' Me.rdoFrequencyTable.Appearance = System.Windows.Forms.Appearance.Button @@ -701,7 +688,6 @@ Partial Class dlgSummaryTables Me.Controls.Add(Me.rdoFrequencyTable) Me.Controls.Add(Me.rdoSummaryTable) Me.Controls.Add(Me.ucrPnlSummaryFrequencyTables) - Me.Controls.Add(Me.cmdFormatTable) Me.Controls.Add(Me.ucrReorderSummary) Me.Controls.Add(Me.lblVariables) Me.Controls.Add(Me.ucrInputMarginName) @@ -763,7 +749,6 @@ Partial Class dlgSummaryTables Friend WithEvents ucrInputMarginName As ucrInputTextBox Friend WithEvents lblVariables As Label Friend WithEvents ucrReorderSummary As ucrReorder - Friend WithEvents cmdFormatTable As Button Friend WithEvents ucrPnlSummaryFrequencyTables As UcrPanel Friend WithEvents rdoFrequencyTable As RadioButton Friend WithEvents rdoSummaryTable As RadioButton diff --git a/instat/dlgSummaryTables.vb b/instat/dlgSummaryTables.vb index 909a040bf8..5239070065 100644 --- a/instat/dlgSummaryTables.vb +++ b/instat/dlgSummaryTables.vb @@ -313,8 +313,18 @@ Public Class dlgSummaryTables End If End Sub + Private Sub btnMoreOptions_Click(sender As Object, e As EventArgs) Handles btnMoreOptions.Click - sdgTableOptions.Setup(ucrSelectorSummaryTables.strCurrentDataFrame, clsJoiningPipeOperator) + Dim clsROperator As ROperator + If rdoFrequencyTable.Checked Then + clsROperator = clsFrequencyOperator + ElseIf rdoSummaryTable.Checked Then + clsROperator = clsSummaryOperator + Else + Exit Sub + End If + + sdgTableOptions.Setup(ucrSelectorSummaryTables.strCurrentDataFrame, clsROperator) sdgTableOptions.ShowDialog(Me) End Sub @@ -338,7 +348,7 @@ Public Class dlgSummaryTables TestOKEnabled() End Sub - Private Sub cmdFormatTable_Click(sender As Object, e As EventArgs) Handles cmdFormatTable.Click + Private Sub cmdFormatTable_Click(sender As Object, e As EventArgs) Dim clsROperator As ROperator If rdoFrequencyTable.Checked Then @@ -385,7 +395,6 @@ Public Class dlgSummaryTables Private Sub ucrPnlSummaryFrequencyTables_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrPnlSummaryFrequencyTables.ControlValueChanged cmdSummaries.Visible = rdoSummaryTable.Checked - cmdFormatTable.Location = New Point(286, If(rdoSummaryTable.Checked, 464, 273)) DialogueSize() SettingParameters() From 7c487403889ee160173caee347112ea52df2e5ec Mon Sep 17 00:00:00 2001 From: patowhiz Date: Fri, 15 Nov 2024 09:02:07 +0300 Subject: [PATCH 3/5] Added gtextras package name --- instat/UserTables/sdgTableOptions.vb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/instat/UserTables/sdgTableOptions.vb b/instat/UserTables/sdgTableOptions.vb index 7140bb5b89..5eb01b1fca 100644 --- a/instat/UserTables/sdgTableOptions.vb +++ b/instat/UserTables/sdgTableOptions.vb @@ -77,10 +77,11 @@ Public Class sdgTableOptions Private Sub SetupTheme(clsOperator As ROperator) clsThemeRFunction = New RFunction + clsThemeRFunction.SetPackageName("gtExtras") ' Uncheck then the check radio button to forces the panel to raise its ControlValueChanged event - rdoSelectTheme.Checked = False - rdoSelectTheme.Checked = True + 'rdoSelectTheme.Checked = False + 'rdoSelectTheme.Checked = True If Not clsOperator.ContainsParameter("theme_format") Then Exit Sub From 5077a3452cff468c3605413172887de7d9658c77 Mon Sep 17 00:00:00 2001 From: patowhiz Date: Fri, 15 Nov 2024 09:11:57 +0300 Subject: [PATCH 4/5] Refactored the code --- instat/UserTables/sdgTableOptions.vb | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/instat/UserTables/sdgTableOptions.vb b/instat/UserTables/sdgTableOptions.vb index 5eb01b1fca..d7fa2263d4 100644 --- a/instat/UserTables/sdgTableOptions.vb +++ b/instat/UserTables/sdgTableOptions.vb @@ -76,26 +76,12 @@ Public Class sdgTableOptions ' Themes Private Sub SetupTheme(clsOperator As ROperator) - clsThemeRFunction = New RFunction - clsThemeRFunction.SetPackageName("gtExtras") - - ' Uncheck then the check radio button to forces the panel to raise its ControlValueChanged event - 'rdoSelectTheme.Checked = False - 'rdoSelectTheme.Checked = True - - If Not clsOperator.ContainsParameter("theme_format") Then - Exit Sub - End If - - clsThemeRFunction = clsOperator.GetParameter("theme_format").clsArgumentCodeStructure - - If clsThemeRFunction.strRCommand = "tab_options" Then - rdoManualTheme.Checked = True + If clsOperator.ContainsParameter("theme_format") Then + clsThemeRFunction = clsOperator.GetParameter("theme_format").clsArgumentCodeStructure Else - rdoSelectTheme.Checked = True - ucrCboSelectThemes.SetName(clsThemeRFunction.strRCommand) + clsThemeRFunction = New RFunction + clsThemeRFunction.SetPackageName("gtExtras") End If - End Sub Private Sub ucrPnlThemes_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrPnlThemesPanel.ControlValueChanged From 4c6ade9d3bd90967386f338b519b502b4b67d52a Mon Sep 17 00:00:00 2001 From: Derrick Agorhom <76208189+derekagorhom@users.noreply.github.com> Date: Fri, 15 Nov 2024 10:22:03 +0100 Subject: [PATCH 5/5] Fixed bug in Labels dialogue --- instat/dlgLabelsLevels.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/dlgLabelsLevels.vb b/instat/dlgLabelsLevels.vb index c3eac2d5c0..a83bc95ce5 100644 --- a/instat/dlgLabelsLevels.vb +++ b/instat/dlgLabelsLevels.vb @@ -80,7 +80,7 @@ Public Class dlgLabelsLevels ucrSelectorForLabels.Focus() - clsSumCountMissingFunction.SetRCommand("summary_count_missing") + clsSumCountMissingFunction.SetRCommand("summary_count_miss") clsViewLabelsFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$set_factor_levels") ucrBase.clsRsyntax.SetBaseRFunction(clsViewLabelsFunction)