From ba702f11f1a5e4be24858bd98159453d9b55af6a Mon Sep 17 00:00:00 2001 From: lilyclements Date: Tue, 5 Nov 2024 16:11:01 +0000 Subject: [PATCH 01/10] adding if statement to param list --- .../R/Backend_Components/summary_functions.R | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/instat/static/InstatObject/R/Backend_Components/summary_functions.R b/instat/static/InstatObject/R/Backend_Components/summary_functions.R index 4124006779..7ce791a1f6 100644 --- a/instat/static/InstatObject/R/Backend_Components/summary_functions.R +++ b/instat/static/InstatObject/R/Backend_Components/summary_functions.R @@ -239,7 +239,7 @@ DataBook$set("public", "calculate_summary", function(data_name, columns_to_summa curr_filter_name <- curr_filter[["name"]] curr_filter_calc <- self$get_filter_as_instat_calculation(data_name, curr_filter_name) manipulations <- c(curr_filter_calc, manipulations) - } + } if(!missing(additional_filter)) { manipulations <- c(additional_filter, manipulations) } @@ -247,10 +247,12 @@ DataBook$set("public", "calculate_summary", function(data_name, columns_to_summa # setting up param_list. Here we read in .drop and .preserve param_list <- list() - for (i in 1:length(combined_calc_sum$manipulations)){ - if (combined_calc_sum$manipulations[[i]]$type %in% c("by", "filter")){ - param_list <- c(param_list, combined_calc_sum$manipulations[[i]]$param_list) - } + if (length(combined_calc_sum$manipulations) > 0){ + for (i in 1:length(combined_calc_sum$manipulations)){ + if (combined_calc_sum$manipulations[[i]]$type %in% c("by", "filter")){ + param_list <- c(param_list, combined_calc_sum$manipulations[[i]]$param_list) + } + } } out <- self$apply_instat_calculation(combined_calc_sum, param_list = param_list) # relocate so that the factors are first still for consistency From 515a5a7b11a7dea18c86ca833f1dbef189141834 Mon Sep 17 00:00:00 2001 From: lilyclements Date: Tue, 5 Nov 2024 16:53:38 +0000 Subject: [PATCH 02/10] Fixing typo in warning message --- instat/clsRLink.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instat/clsRLink.vb b/instat/clsRLink.vb index 2f4112aab9..bbaaab6c1f 100644 --- a/instat/clsRLink.vb +++ b/instat/clsRLink.vb @@ -201,8 +201,8 @@ Public Class RLink MsgBox(ex.Message & Environment.NewLine & "Could not establish connection to R." & Environment.NewLine & "R-Instat requires version " & strRVersionRequired & " of R." & Environment.NewLine & "Note that R-Instat does not work with R below 4.4.1. We recommend using R " & strRBundledVersion & - ". Try reruning the installation to install R " & strRBundledVersion & " or download R " & - strRBundledVersion & " from https://cran.r-project.org/bin/windows/base/old/" & strRBundledVersion & "/ and restart R-Instat.", + ". Try rerunning the installation to install R " & strRBundledVersion & " or download R " & + strRBundledVersion & " from https://cran.r-project.org/bin/windows/base/old/" & strRBundledVersion & "/ and restart R-Instat.", MsgBoxStyle.Critical, "Cannot initialise R connection.") End Try From a556cf9c2508fe9b92e7ac7f9a332f1a3b5fb1d3 Mon Sep 17 00:00:00 2001 From: lilyclements Date: Tue, 5 Nov 2024 16:54:57 +0000 Subject: [PATCH 03/10] typo fixes --- instat/clsRLink.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/clsRLink.vb b/instat/clsRLink.vb index bbaaab6c1f..e1d6f7b28a 100644 --- a/instat/clsRLink.vb +++ b/instat/clsRLink.vb @@ -228,7 +228,7 @@ Public Class RLink MsgBox("Could not determine version of R installed on your machine. R-Instat requires version: " & strRVersionRequired & vbNewLine & "Try uninstalling any versions of R and rerun the installation to install R " & strRVersionRequired & " or download R " & strRVersionRequired & "From https://cran.r-project.org/bin/windows/base/old/" & strRVersionRequired & - "And restart R-Instat.", + " and restart R-Instat.", MsgBoxStyle.Critical, "R Version error.") ElseIf strMajor <> strRVersionMajorRequired OrElse strMinor.Substring(0, 1) < strRVersionMinorRequired Then MsgBox("Your current version of R is outdated. You are currently running R version: " & strMajor & "." & strMinor & Environment.NewLine & From 440e32672601d2acb3e64c7f54fc481e8ae0d288 Mon Sep 17 00:00:00 2001 From: lilyclements Date: Wed, 6 Nov 2024 14:19:16 +0000 Subject: [PATCH 04/10] fixing bug in summary_cor given update in R versions --- .../InstatObject/R/Backend_Components/summary_functions.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/instat/static/InstatObject/R/Backend_Components/summary_functions.R b/instat/static/InstatObject/R/Backend_Components/summary_functions.R index 7ce791a1f6..397a72b261 100644 --- a/instat/static/InstatObject/R/Backend_Components/summary_functions.R +++ b/instat/static/InstatObject/R/Backend_Components/summary_functions.R @@ -1065,11 +1065,12 @@ summary_Sn <- function(x, constant = 1.1926, finite.corr = missing(constant), na } # cor function -summary_cor <- function(x, y, na.rm = FALSE, na_type = "", weights = NULL, method = c("pearson", "kendall", "spearman"), use = c( "everything", "all.obs", "complete.obs", "na.or.complete", "pairwise.complete.obs"), ...) { +summary_cor <- function(x, y, na.rm = FALSE, na_type = "", weights = NULL, method = c("pearson", "kendall", "spearman"), cor_use = c("everything", "all.obs", "complete.obs", "na.or.complete", "pairwise.complete.obs"), ...) { + cor_use <- match.arg(cor_use) if (na.rm && na_type != "" && !na_check(x, na_type = na_type, ...)) return(NA) else { if (missing(weights) || is.null(weights)) { - return(cor(x = x, y = y, use = use, method = method)) + return(cor(x = x, y = y, use = cor_use, method = method)) } else { weights::wtd.cor(x = x, y = y, weight = weights)[1] From f196f8205ec4531d43fe23dd92d61965e3da2a63 Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Thu, 7 Nov 2024 10:12:29 +0300 Subject: [PATCH 05/10] printing the results to the output if not factors selected --- instat/dlgColumnStats.vb | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/instat/dlgColumnStats.vb b/instat/dlgColumnStats.vb index 2ea3642cb8..418f9e47f6 100644 --- a/instat/dlgColumnStats.vb +++ b/instat/dlgColumnStats.vb @@ -157,11 +157,7 @@ Public Class dlgColumnStats End Sub Public Sub TestOKEnabled() - If ((ucrChkStoreResults.Checked OrElse ucrChkPrintOutput.Checked) AndAlso Not clsSummariesList.clsParameters.Count = 0) AndAlso sdgSummaries.bOkEnabled Then - ucrBase.OKEnabled(True) - Else - ucrBase.OKEnabled(False) - End If + ucrBase.OKEnabled(Not clsSummariesList.clsParameters.Count = 0 AndAlso sdgSummaries.bOkEnabled AndAlso Not ucrReceiverSelectedVariables.IsEmpty) End Sub Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset @@ -226,14 +222,20 @@ Public Class dlgColumnStats sdgMissingOptions.ShowDialog() End Sub - 'Private Sub ucrReceiverSelectedVariables_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverSelectedVariables.ControlValueChanged - ' Dim bSameType As Boolean = Not ucrReceiverSelectedVariables.IsEmpty _ - ' AndAlso ucrReceiverSelectedVariables.GetCurrentItemTypes().All(Function(x) x = "factor") - ' ucrChkDropUnusedLevels.Enabled = bSameType - ' ucrChkDropUnusedLevels.Checked = Not bSameType - 'End Sub + Private Sub ucrReceiverSelectedVariables_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverSelectedVariables.ControlValueChanged, ucrChkStoreResults.ControlValueChanged, ucrChkPrintOutput.ControlValueChanged + If Not ucrReceiverSelectedVariables.IsEmpty _ + AndAlso Not ucrReceiverSelectedVariables.GetCurrentItemTypes().Any(Function(x) x = "factor") Then + clsDefaultFunction.AddParameter("store_results", "FALSE", iPosition:=3) + clsDefaultFunction.AddParameter("return_output", "TRUE", iPosition:=4) + ucrBase.clsRsyntax.iCallType = 2 + Else + If ucrChkStoreResults.Checked Then + clsDefaultFunction.AddParameter("store_results", "TRUE", iPosition:=3) + End If + End If + End Sub - Private Sub CoreControls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrChkPrintOutput.ControlContentsChanged, ucrChkStoreResults.ControlContentsChanged + Private Sub CoreControls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverSelectedVariables.ControlContentsChanged TestOKEnabled() End Sub End Class From f1f850b8876fdbc752050b65a1762ed52666c7c6 Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Thu, 7 Nov 2024 10:23:26 +0300 Subject: [PATCH 06/10] minor addition --- instat/dlgColumnStats.vb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/instat/dlgColumnStats.vb b/instat/dlgColumnStats.vb index 418f9e47f6..9b3fee38a1 100644 --- a/instat/dlgColumnStats.vb +++ b/instat/dlgColumnStats.vb @@ -232,6 +232,9 @@ Public Class dlgColumnStats If ucrChkStoreResults.Checked Then clsDefaultFunction.AddParameter("store_results", "TRUE", iPosition:=3) End If + If ucrChkPrintOutput.Checked Then + clsDefaultFunction.AddParameter("return_output", "TRUE", iPosition:=4) + End If End If End Sub From 872909edf293822bb8ff22c1a283f73a89ec46bc Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Thu, 7 Nov 2024 10:27:31 +0300 Subject: [PATCH 07/10] minor addition --- instat/dlgColumnStats.vb | 1 + 1 file changed, 1 insertion(+) diff --git a/instat/dlgColumnStats.vb b/instat/dlgColumnStats.vb index 9b3fee38a1..1f788556c7 100644 --- a/instat/dlgColumnStats.vb +++ b/instat/dlgColumnStats.vb @@ -229,6 +229,7 @@ Public Class dlgColumnStats clsDefaultFunction.AddParameter("return_output", "TRUE", iPosition:=4) ucrBase.clsRsyntax.iCallType = 2 Else + clsDefaultFunction.RemoveParameterByName("return_output") If ucrChkStoreResults.Checked Then clsDefaultFunction.AddParameter("store_results", "TRUE", iPosition:=3) End If From eeb6472d66f41a34b5de6c01d8bf9bc48653265a Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Thu, 7 Nov 2024 12:21:12 +0300 Subject: [PATCH 08/10] minor code change --- instat/dlgColumnStats.vb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/instat/dlgColumnStats.vb b/instat/dlgColumnStats.vb index 1f788556c7..2555fdab7a 100644 --- a/instat/dlgColumnStats.vb +++ b/instat/dlgColumnStats.vb @@ -222,9 +222,9 @@ Public Class dlgColumnStats sdgMissingOptions.ShowDialog() End Sub - Private Sub ucrReceiverSelectedVariables_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverSelectedVariables.ControlValueChanged, ucrChkStoreResults.ControlValueChanged, ucrChkPrintOutput.ControlValueChanged - If Not ucrReceiverSelectedVariables.IsEmpty _ - AndAlso Not ucrReceiverSelectedVariables.GetCurrentItemTypes().Any(Function(x) x = "factor") Then + Private Sub ucrReceiverByFactor_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverByFactor.ControlValueChanged, ucrChkStoreResults.ControlValueChanged, ucrChkPrintOutput.ControlValueChanged + If ucrReceiverByFactor.IsEmpty _ + OrElse Not ucrReceiverByFactor.GetCurrentItemTypes().Any(Function(x) x = "factor") Then clsDefaultFunction.AddParameter("store_results", "FALSE", iPosition:=3) clsDefaultFunction.AddParameter("return_output", "TRUE", iPosition:=4) ucrBase.clsRsyntax.iCallType = 2 From 47ba08f52a25ae66726ce25e0aa7b260ec0249c6 Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Thu, 7 Nov 2024 13:43:16 +0300 Subject: [PATCH 09/10] removed the checking of factor in summary by receiver --- instat/dlgColumnStats.vb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/instat/dlgColumnStats.vb b/instat/dlgColumnStats.vb index 2555fdab7a..234cb15699 100644 --- a/instat/dlgColumnStats.vb +++ b/instat/dlgColumnStats.vb @@ -223,8 +223,7 @@ Public Class dlgColumnStats End Sub Private Sub ucrReceiverByFactor_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverByFactor.ControlValueChanged, ucrChkStoreResults.ControlValueChanged, ucrChkPrintOutput.ControlValueChanged - If ucrReceiverByFactor.IsEmpty _ - OrElse Not ucrReceiverByFactor.GetCurrentItemTypes().Any(Function(x) x = "factor") Then + If ucrReceiverByFactor.IsEmpty Then clsDefaultFunction.AddParameter("store_results", "FALSE", iPosition:=3) clsDefaultFunction.AddParameter("return_output", "TRUE", iPosition:=4) ucrBase.clsRsyntax.iCallType = 2 From e6b7df85891c08cfa9631edf57e0148e33b72062 Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Thu, 7 Nov 2024 14:35:52 +0300 Subject: [PATCH 10/10] default state change for printing --- instat/dlgColumnStats.vb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/instat/dlgColumnStats.vb b/instat/dlgColumnStats.vb index 234cb15699..4a2e6621f6 100644 --- a/instat/dlgColumnStats.vb +++ b/instat/dlgColumnStats.vb @@ -72,10 +72,7 @@ Public Class dlgColumnStats ucrChkOriginalLevel.SetValuesCheckedAndUnchecked("TRUE", "FALSE") ucrChkOriginalLevel.SetRDefault("FALSE") - ucrChkPrintOutput.SetParameter(New RParameter("return_output", 4)) ucrChkPrintOutput.SetText("Print Results to Output Window") - ucrChkPrintOutput.SetValuesCheckedAndUnchecked("TRUE", "FALSE") - ucrChkPrintOutput.SetRDefault("FALSE") ucrChkDropUnusedLevels.SetParameter(New RParameter("drop", 5)) ucrChkDropUnusedLevels.SetText("Drop Unused Levels") @@ -117,6 +114,7 @@ Public Class dlgColumnStats clsDefaultFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$calculate_summary") clsDefaultFunction.AddParameter("summaries", clsRFunctionParameter:=clsSummariesList) + clsDefaultFunction.AddParameter("store_results", "TRUE", iPosition:=3) 'Prevents an error if user chooses non count summaries with no columns to summarise clsDefaultFunction.AddParameter("silent", "TRUE") ucrBase.clsRsyntax.SetBaseRFunction(clsDefaultFunction)