diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index cc948147285..328705a201a 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -104,7 +104,7 @@ jobs: - name: Checkout Instat Data uses: actions/checkout@v3 with: - repository: ' africanmathsinitiative/R-Instat-Data' + repository: ' IDEMSInternational/R-Instat-Data' fetch-depth: 0 path: 'InstatData' diff --git a/instat/UserTables/sdgTableOptions.vb b/instat/UserTables/sdgTableOptions.vb index 7140bb5b89d..d7fa2263d43 100644 --- a/instat/UserTables/sdgTableOptions.vb +++ b/instat/UserTables/sdgTableOptions.vb @@ -76,25 +76,12 @@ Public Class sdgTableOptions ' Themes Private Sub SetupTheme(clsOperator As ROperator) - clsThemeRFunction = New RFunction - - ' 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 diff --git a/instat/dlgClimaticSummary.vb b/instat/dlgClimaticSummary.vb index b91b6e66159..122ed4dfdcd 100644 --- a/instat/dlgClimaticSummary.vb +++ b/instat/dlgClimaticSummary.vb @@ -194,8 +194,7 @@ Public Class dlgClimaticSummary 'TODO: what defaults do we want? clsSummariesList.SetRCommand("c") - clsSummariesList.AddParameter("summary_count_non_missing", Chr(34) & "summary_count_non_missing" & Chr(34), bIncludeArgumentName:=False, iPosition:=1) - clsSummariesList.AddParameter("summary_count", Chr(34) & "summary_count" & Chr(34), bIncludeArgumentName:=False, iPosition:=3) + clsSummariesList.AddParameter("summary_count", Chr(34) & "summary_count" & Chr(34), bIncludeArgumentName:=False, iPosition:=1) clsSummariesList.AddParameter("summary_sum", Chr(34) & "summary_sum" & Chr(34), bIncludeArgumentName:=False, iPosition:=11) clsDefaultFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$calculate_summary") diff --git a/instat/dlgColumnStats.vb b/instat/dlgColumnStats.vb index 7769627a284..1fc55717efa 100644 --- a/instat/dlgColumnStats.vb +++ b/instat/dlgColumnStats.vb @@ -109,7 +109,7 @@ Public Class dlgColumnStats clsConcFunction.SetRCommand("c") clsSummariesList.SetRCommand("c") - clsSummariesList.AddParameter("summary_count_non_missing", Chr(34) & "summary_count_non_missing" & Chr(34), bIncludeArgumentName:=False, iPosition:=1) + clsSummariesList.AddParameter("summary_count", Chr(34) & "summary_count" & Chr(34), bIncludeArgumentName:=False, iPosition:=1) clsSummariesList.AddParameter("summary_sum", Chr(34) & "summary_sum" & Chr(34), bIncludeArgumentName:=False, iPosition:=11) clsDefaultFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$calculate_summary") diff --git a/instat/dlgDescribeTwoVariable.Designer.vb b/instat/dlgDescribeTwoVariable.Designer.vb index fe9da77487d..5eb45c48ae7 100644 --- a/instat/dlgDescribeTwoVariable.Designer.vb +++ b/instat/dlgDescribeTwoVariable.Designer.vb @@ -60,6 +60,8 @@ Partial Class dlgDescribeTwoVariable Me.cmdSummaries = New System.Windows.Forms.Button() Me.lblMarginName = New System.Windows.Forms.Label() Me.grpDisplay = New System.Windows.Forms.GroupBox() + Me.ucrReceiverColumns = New instat.ucrReceiverMultiple() + Me.ucrChkDisplayAsPercentage = New instat.ucrCheck() Me.rdoOCol = New System.Windows.Forms.RadioButton() Me.rdoOCell = New System.Windows.Forms.RadioButton() Me.rdoORow = New System.Windows.Forms.RadioButton() @@ -70,8 +72,6 @@ Partial Class dlgDescribeTwoVariable Me.ucrReceiverSecondTwoVariableFactor = New instat.ucrReceiverSingle() Me.ucrReceiverFirstVars = New instat.ucrReceiverMultiple() Me.ucrSaveTable = New instat.ucrSave() - Me.ucrReceiverColumns = New instat.ucrReceiverMultiple() - Me.ucrChkDisplayAsPercentage = New instat.ucrCheck() Me.ucrInputMarginName = New instat.ucrInputTextBox() Me.ucrReorderSummary = New instat.ucrReorder() Me.ucrBase = New instat.ucrButtons() @@ -80,13 +80,13 @@ Partial Class dlgDescribeTwoVariable Me.ucrPnlDescribe = New instat.UcrPanel() Me.ucrReceiverSkimrGroupByFactor = New instat.ucrReceiverSingle() Me.ucrChkDisplayMargins = New instat.ucrCheck() - Me.ucrChkSummariesRowCol = New instat.ucrCheck() Me.ucrChkLevSig = New instat.ucrCheck() Me.ucrChkTotal = New instat.ucrCheck() Me.ucrChkMeans = New instat.ucrCheck() Me.ucrChkCorrelations = New instat.ucrCheck() Me.ucrChkSwapXYVar = New instat.ucrCheck() Me.ucrChkOmitMissing = New instat.ucrCheck() + Me.ucrChkInteraction = New instat.ucrCheck() Me.grpSummaries.SuspendLayout() Me.grpDisplay.SuspendLayout() Me.SuspendLayout() @@ -350,19 +350,42 @@ Partial Class dlgDescribeTwoVariable ' Me.grpDisplay.Controls.Add(Me.ucrReceiverColumns) Me.grpDisplay.Controls.Add(Me.ucrChkDisplayAsPercentage) - Me.grpDisplay.Location = New System.Drawing.Point(414, 278) + Me.grpDisplay.Location = New System.Drawing.Point(414, 286) Me.grpDisplay.Margin = New System.Windows.Forms.Padding(4) Me.grpDisplay.Name = "grpDisplay" Me.grpDisplay.Padding = New System.Windows.Forms.Padding(4) - Me.grpDisplay.Size = New System.Drawing.Size(291, 219) + Me.grpDisplay.Size = New System.Drawing.Size(291, 265) Me.grpDisplay.TabIndex = 15 Me.grpDisplay.TabStop = False Me.grpDisplay.Text = "Percentages" ' + 'ucrReceiverColumns + ' + Me.ucrReceiverColumns.AutoSize = True + Me.ucrReceiverColumns.frmParent = Me + Me.ucrReceiverColumns.Location = New System.Drawing.Point(40, 138) + Me.ucrReceiverColumns.Margin = New System.Windows.Forms.Padding(0) + Me.ucrReceiverColumns.Name = "ucrReceiverColumns" + Me.ucrReceiverColumns.Selector = Nothing + Me.ucrReceiverColumns.Size = New System.Drawing.Size(180, 123) + Me.ucrReceiverColumns.strNcFilePath = "" + Me.ucrReceiverColumns.TabIndex = 46 + Me.ucrReceiverColumns.ucrSelector = Nothing + ' + 'ucrChkDisplayAsPercentage + ' + Me.ucrChkDisplayAsPercentage.AutoSize = True + Me.ucrChkDisplayAsPercentage.Checked = False + Me.ucrChkDisplayAsPercentage.Location = New System.Drawing.Point(21, 32) + Me.ucrChkDisplayAsPercentage.Margin = New System.Windows.Forms.Padding(9) + Me.ucrChkDisplayAsPercentage.Name = "ucrChkDisplayAsPercentage" + Me.ucrChkDisplayAsPercentage.Size = New System.Drawing.Size(256, 36) + Me.ucrChkDisplayAsPercentage.TabIndex = 54 + ' 'rdoOCol ' Me.rdoOCol.AutoSize = True - Me.rdoOCol.Location = New System.Drawing.Point(432, 336) + Me.rdoOCol.Location = New System.Drawing.Point(432, 357) Me.rdoOCol.Name = "rdoOCol" Me.rdoOCol.Size = New System.Drawing.Size(81, 24) Me.rdoOCol.TabIndex = 40 @@ -373,7 +396,7 @@ Partial Class dlgDescribeTwoVariable 'rdoOCell ' Me.rdoOCell.AutoSize = True - Me.rdoOCell.Location = New System.Drawing.Point(612, 334) + Me.rdoOCell.Location = New System.Drawing.Point(612, 355) Me.rdoOCell.Name = "rdoOCell" Me.rdoOCell.Size = New System.Drawing.Size(84, 24) Me.rdoOCell.TabIndex = 41 @@ -384,7 +407,7 @@ Partial Class dlgDescribeTwoVariable 'rdoORow ' Me.rdoORow.AutoSize = True - Me.rdoORow.Location = New System.Drawing.Point(518, 336) + Me.rdoORow.Location = New System.Drawing.Point(518, 357) Me.rdoORow.Name = "rdoORow" Me.rdoORow.Size = New System.Drawing.Size(90, 24) Me.rdoORow.TabIndex = 42 @@ -409,7 +432,7 @@ Partial Class dlgDescribeTwoVariable ' Me.ucrReceiverPercentages.AutoSize = True Me.ucrReceiverPercentages.frmParent = Me - Me.ucrReceiverPercentages.Location = New System.Drawing.Point(430, 369) + Me.ucrReceiverPercentages.Location = New System.Drawing.Point(430, 390) Me.ucrReceiverPercentages.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverPercentages.Name = "ucrReceiverPercentages" Me.ucrReceiverPercentages.Selector = Nothing @@ -421,7 +444,7 @@ Partial Class dlgDescribeTwoVariable 'ucrpnlPercent ' Me.ucrpnlPercent.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrpnlPercent.Location = New System.Drawing.Point(424, 332) + Me.ucrpnlPercent.Location = New System.Drawing.Point(424, 353) Me.ucrpnlPercent.Margin = New System.Windows.Forms.Padding(6, 6, 6, 6) Me.ucrpnlPercent.Name = "ucrpnlPercent" Me.ucrpnlPercent.Size = New System.Drawing.Size(270, 38) @@ -475,29 +498,6 @@ Partial Class dlgDescribeTwoVariable Me.ucrSaveTable.Size = New System.Drawing.Size(459, 36) Me.ucrSaveTable.TabIndex = 24 ' - 'ucrReceiverColumns - ' - Me.ucrReceiverColumns.AutoSize = True - Me.ucrReceiverColumns.frmParent = Nothing - Me.ucrReceiverColumns.Location = New System.Drawing.Point(20, 92) - Me.ucrReceiverColumns.Margin = New System.Windows.Forms.Padding(0) - Me.ucrReceiverColumns.Name = "ucrReceiverColumns" - Me.ucrReceiverColumns.Selector = Nothing - Me.ucrReceiverColumns.Size = New System.Drawing.Size(180, 122) - Me.ucrReceiverColumns.strNcFilePath = "" - Me.ucrReceiverColumns.TabIndex = 55 - Me.ucrReceiverColumns.ucrSelector = Nothing - ' - 'ucrChkDisplayAsPercentage - ' - Me.ucrChkDisplayAsPercentage.AutoSize = True - Me.ucrChkDisplayAsPercentage.Checked = False - Me.ucrChkDisplayAsPercentage.Location = New System.Drawing.Point(14, 22) - Me.ucrChkDisplayAsPercentage.Margin = New System.Windows.Forms.Padding(6, 6, 6, 6) - Me.ucrChkDisplayAsPercentage.Name = "ucrChkDisplayAsPercentage" - Me.ucrChkDisplayAsPercentage.Size = New System.Drawing.Size(171, 51) - Me.ucrChkDisplayAsPercentage.TabIndex = 54 - ' 'ucrInputMarginName ' Me.ucrInputMarginName.AddQuotesIfUnrecognised = True @@ -512,7 +512,7 @@ Partial Class dlgDescribeTwoVariable ' 'ucrReorderSummary ' - Me.ucrReorderSummary.Location = New System.Drawing.Point(412, 409) + Me.ucrReorderSummary.Location = New System.Drawing.Point(412, 410) Me.ucrReorderSummary.Margin = New System.Windows.Forms.Padding(9) Me.ucrReorderSummary.Name = "ucrReorderSummary" Me.ucrReorderSummary.Size = New System.Drawing.Size(291, 234) @@ -587,16 +587,6 @@ Partial Class dlgDescribeTwoVariable Me.ucrChkDisplayMargins.Size = New System.Drawing.Size(214, 34) Me.ucrChkDisplayMargins.TabIndex = 18 ' - 'ucrChkSummariesRowCol - ' - Me.ucrChkSummariesRowCol.AutoSize = True - Me.ucrChkSummariesRowCol.Checked = False - Me.ucrChkSummariesRowCol.Location = New System.Drawing.Point(22, 507) - Me.ucrChkSummariesRowCol.Margin = New System.Windows.Forms.Padding(9) - Me.ucrChkSummariesRowCol.Name = "ucrChkSummariesRowCol" - Me.ucrChkSummariesRowCol.Size = New System.Drawing.Size(270, 34) - Me.ucrChkSummariesRowCol.TabIndex = 20 - ' 'ucrChkLevSig ' Me.ucrChkLevSig.AutoSize = True @@ -641,7 +631,7 @@ Partial Class dlgDescribeTwoVariable ' Me.ucrChkSwapXYVar.AutoSize = True Me.ucrChkSwapXYVar.Checked = False - Me.ucrChkSwapXYVar.Location = New System.Drawing.Point(465, 347) + Me.ucrChkSwapXYVar.Location = New System.Drawing.Point(465, 346) Me.ucrChkSwapXYVar.Margin = New System.Windows.Forms.Padding(9) Me.ucrChkSwapXYVar.Name = "ucrChkSwapXYVar" Me.ucrChkSwapXYVar.Size = New System.Drawing.Size(236, 34) @@ -657,6 +647,16 @@ Partial Class dlgDescribeTwoVariable Me.ucrChkOmitMissing.Size = New System.Drawing.Size(214, 34) Me.ucrChkOmitMissing.TabIndex = 0 ' + 'ucrChkInteraction + ' + Me.ucrChkInteraction.AutoSize = True + Me.ucrChkInteraction.Checked = False + Me.ucrChkInteraction.Location = New System.Drawing.Point(465, 380) + Me.ucrChkInteraction.Margin = New System.Windows.Forms.Padding(9) + Me.ucrChkInteraction.Name = "ucrChkInteraction" + Me.ucrChkInteraction.Size = New System.Drawing.Size(214, 34) + Me.ucrChkInteraction.TabIndex = 45 + ' 'dlgDescribeTwoVariable ' Me.AutoScaleDimensions = New System.Drawing.SizeF(144.0!, 144.0!) @@ -664,8 +664,10 @@ Partial Class dlgDescribeTwoVariable Me.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink Me.ClientSize = New System.Drawing.Size(723, 700) Me.Controls.Add(Me.cmdSummaries) - Me.Controls.Add(Me.ucrReceiverThreeVariableThirdVariable) Me.Controls.Add(Me.ucrReceiverPercentages) + Me.Controls.Add(Me.ucrReorderSummary) + Me.Controls.Add(Me.ucrChkInteraction) + Me.Controls.Add(Me.ucrReceiverThreeVariableThirdVariable) Me.Controls.Add(Me.rdoORow) Me.Controls.Add(Me.rdoOCell) Me.Controls.Add(Me.rdoOCol) @@ -676,7 +678,6 @@ Partial Class dlgDescribeTwoVariable Me.Controls.Add(Me.ucrSaveTable) Me.Controls.Add(Me.grpDisplay) Me.Controls.Add(Me.ucrInputMarginName) - Me.Controls.Add(Me.ucrReorderSummary) Me.Controls.Add(Me.lblMarginName) Me.Controls.Add(Me.cmdFormatTable) Me.Controls.Add(Me.ucrBase) @@ -695,7 +696,6 @@ Partial Class dlgDescribeTwoVariable Me.Controls.Add(Me.lblThreeVariableSecondFactor) Me.Controls.Add(Me.ucrChkDisplayMargins) Me.Controls.Add(Me.cmdMissingOptions) - Me.Controls.Add(Me.ucrChkSummariesRowCol) Me.Controls.Add(Me.lblThirdVariable) Me.Controls.Add(Me.ucrChkLevSig) Me.Controls.Add(Me.ucrChkTotal) @@ -710,7 +710,7 @@ Partial Class dlgDescribeTwoVariable Me.Name = "dlgDescribeTwoVariable" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Tag = "Describe_Two_Variable" - Me.Text = "Describe Two Variables" + Me.Text = "Summarise Two/Three Variables" Me.grpSummaries.ResumeLayout(False) Me.grpSummaries.PerformLayout() Me.grpDisplay.ResumeLayout(False) @@ -756,7 +756,6 @@ Partial Class dlgDescribeTwoVariable Friend WithEvents ucrChkDisplayAsPercentage As ucrCheck Friend WithEvents ucrSaveTable As ucrSave Friend WithEvents ucrReceiverFirstVars As ucrReceiverMultiple - Friend WithEvents ucrChkSummariesRowCol As ucrCheck Friend WithEvents ucrChkCorrelations As ucrCheck Friend WithEvents ucrChkSwapXYVar As ucrCheck Friend WithEvents ucrChkMeans As ucrCheck @@ -766,6 +765,7 @@ Partial Class dlgDescribeTwoVariable Friend WithEvents rdoOCell As RadioButton Friend WithEvents rdoOCol As RadioButton Friend WithEvents ucrpnlPercent As UcrPanel - Friend WithEvents ucrReceiverColumns As ucrReceiverMultiple Friend WithEvents ucrChkTotal As ucrCheck + Friend WithEvents ucrChkInteraction As ucrCheck + Friend WithEvents ucrReceiverColumns As ucrReceiverMultiple End Class diff --git a/instat/dlgDescribeTwoVariable.vb b/instat/dlgDescribeTwoVariable.vb index 7c0bf0f82d2..0da50e2892b 100644 --- a/instat/dlgDescribeTwoVariable.vb +++ b/instat/dlgDescribeTwoVariable.vb @@ -42,7 +42,7 @@ Public Class dlgDescribeTwoVariable clsTabFootnoteSubtitleFunction, clsTabFootnoteTitleFunction, clsTableSourcenoteFunction, clsTableTitleFunction, clsThemesTabOptionFunction, clsTabStyleCellTextFunction, clsTabStyleCellTitleFunction, clsTabStyleFunction, - clsTabStylePxFunction, clsgtExtrasThemesFuction As New RFunction + clsTabStylePxFunction, clsgtExtrasThemesFuction, clsCrossDfFunction, clsListFunction As New RFunction Private clsGroupByPipeOperator, clsSummaryOperator, clsGroupByPipeOperator2, clsGroupByPipeOperator3, clsGroupByPipeOperator4, clsGroupByPipeOperatorData As New ROperator @@ -50,14 +50,14 @@ Public Class dlgDescribeTwoVariable Private clsTildOperator, clsMapOperator, clsPivotOperator As New ROperator - Private clsgtFunction, clsMapSummaryFunction, clsMapGtFunction As New RFunction + Private clsgtFunction, clsMapSummaryFunction, clsMap2SummaryFunction, clsMapGtFunction As New RFunction 'Frequency Parameters Private lstFrequencyParameters As New List(Of String)({"percentage_type", "margin_name", "perc_total_factors", "perc_decimal", "signif_fig", "include_margins"}) 'Format Operators - Private clsPipeOperator, clsTabFootnoteOperator, + Private clsPipeOperator, clsFactorOperator, clsSummariesOperator, clsTabFootnoteOperator, clsJoiningPipeOperator, clsMutableOperator, clsAnovaSwapTable2Opeator, clsAnovaTable2Operator, clsYlist2Operator, clsYlistOperator As New ROperator Private iUcrBaseXLocation, iDialogueXsize As Integer @@ -73,6 +73,7 @@ Public Class dlgDescribeTwoVariable SetHelpOptions() bReset = False TestOKEnabled() + ManageControlsVisibility() autoTranslate(Me) End Sub @@ -145,10 +146,6 @@ Public Class dlgDescribeTwoVariable ucrChkDisplayAsPercentage.AddToLinkedControls(ucrReceiverPercentages, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedUpdateFunction:=True) ucrChkDisplayAsPercentage.AddToLinkedControls(ucrpnlPercent, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) - ucrChkSummariesRowCol.SetText("Summaries in Rows") - ucrChkSummariesRowCol.AddParameterValuesCondition(True, "row_sum", "True") - ucrChkSummariesRowCol.AddParameterValuesCondition(False, "row_sum", "False") - ucrChkCorrelations.SetText("Correlations") ucrChkCorrelations.AddParameterValuesCondition(True, "corr", "True") ucrChkCorrelations.AddParameterValuesCondition(False, "corr", "False") @@ -164,10 +161,15 @@ Public Class dlgDescribeTwoVariable ucrChkLevSig.SetRDefault("FALSE") ucrChkTotal.SetText("Total") - ucrChkTotal.SetParameter(New RParameter("total", 5)) + ucrChkTotal.SetParameter(New RParameter("total", 6)) ucrChkTotal.SetValuesCheckedAndUnchecked("TRUE", "FALSE") ucrChkTotal.SetRDefault("FALSE") + ucrChkInteraction.SetText("Interaction") + ucrChkInteraction.SetParameter(New RParameter("interaction", 5)) + ucrChkInteraction.SetValuesCheckedAndUnchecked("TRUE", "FALSE") + ucrChkInteraction.SetRDefault("FALSE") + ucrChkSwapXYVar.SetText("Swap First/Second Variables") ucrChkSwapXYVar.AddParameterValuesCondition(True, "var", "True") ucrChkSwapXYVar.AddParameterValuesCondition(False, "var", "False") @@ -187,7 +189,7 @@ Public Class dlgDescribeTwoVariable ucrpnlPercent.AddParameterValuesCondition(rdoOCell, "percent", "cell") ucrPnlDescribe.AddToLinkedControls({ucrReceiverSkimrGroupByFactor, ucrReceiverSecondSkimrGroupByFactor}, {rdoSkim}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) - ucrPnlDescribe.AddToLinkedControls({ucrReceiverThreeVariableThirdVariable}, {rdoThreeVariable}, bNewLinkedHideIfParameterMissing:=True) + ucrPnlDescribe.AddToLinkedControls({ucrReceiverThreeVariableThirdVariable}, {rdoThreeVariable}, bNewLinkedHideIfParameterMissing:=True, bNewLinkedAddRemoveParameter:=True) ucrPnlDescribe.AddToLinkedControls({ucrReceiverSecondTwoVariableFactor}, {rdoTwoVariable}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrPnlDescribe.AddToLinkedControls({ucrReceiverThreeVariableSecondFactor}, {rdoThreeVariable}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) @@ -201,9 +203,10 @@ Public Class dlgDescribeTwoVariable ucrSaveTable.SetDataFrameSelector(ucrSelectorDescribeTwoVar.ucrAvailableDataFrames) ucrSaveTable.SetIsTextBox() - rdoThreeVariable.Enabled = False ucrReorderSummary.bDataIsSummaries = True AddRemoveTotalParm() + AddInteraction() + ManageControlsVisibility() End Sub Private Sub SetDefaults() @@ -264,11 +267,16 @@ Public Class dlgDescribeTwoVariable clsYlist2Operator = New ROperator clsRAnovaTable2Function = New RFunction clsRAnovaSwapTable2Funtion = New RFunction + clsCrossDfFunction = New RFunction + clsListFunction = New RFunction + clsMap2SummaryFunction = New RFunction clsTildOperator = New ROperator clsMapSummaryFunction = New RFunction clsMapGtFunction = New RFunction clsPivotOperator = New ROperator + clsFactorOperator = New ROperator + clsSummariesOperator = New ROperator ucrSelectorDescribeTwoVar.Reset() ucrReceiverFirstVars.SetMeAsReceiver() @@ -281,6 +289,25 @@ Public Class dlgDescribeTwoVariable clsCombineFunction.SetRCommand("c") + clsSummariesOperator.SetOperation("", bBracketsTemp:=False) + clsSummariesOperator.SetAssignTo("summaries") + + clsFactorOperator.SetOperation("", bBracketsTemp:=False) + clsFactorOperator.SetAssignTo("factors") + + clsListFunction.SetRCommand("list") + clsListFunction.AddParameter("factor", "factors", iPosition:=0) + clsListFunction.AddParameter("summary", "summaries", iPosition:=1) + + clsCrossDfFunction.SetRCommand("cross_df") + clsCrossDfFunction.AddParameter("list", clsRFunctionParameter:=clsListFunction, iPosition:=0, bIncludeArgumentName:=False) + clsCrossDfFunction.SetAssignTo("combinations") + + clsMap2SummaryFunction.SetPackageName("purrr") + clsMap2SummaryFunction.SetRCommand("map2") + clsMap2SummaryFunction.AddParameter(".x", "combinations$factor", iPosition:=0) + clsMap2SummaryFunction.AddParameter(".y", "combinations$summary", iPosition:=1) + clsDummyFunction.AddParameter("checked", "skim", iPosition:=0) clsDummyFunction.AddParameter("factor_cols", "Sum", iPosition:=1) clsDummyFunction.AddParameter("theme", "select", iPosition:=2) @@ -426,7 +453,6 @@ Public Class dlgDescribeTwoVariable clsMapSummaryFunction.SetPackageName("purrr") clsMapSummaryFunction.SetRCommand("map") - clsMapSummaryFunction.AddParameter(".f", clsROperatorParameter:=clsMapOperator, iPosition:=1) clsMapGtFunction.SetPackageName("purrr") clsMapGtFunction.SetRCommand("map") @@ -437,7 +463,6 @@ Public Class dlgDescribeTwoVariable clsSummaryOperator.SetOperation("%>%") clsSummaryOperator.AddParameter("data", clsRFunctionParameter:=ucrSelectorDescribeTwoVar.ucrAvailableDataFrames.clsCurrDataFrame, iPosition:=0) - clsSummaryOperator.AddParameter("tableFun", clsRFunctionParameter:=clsMapSummaryFunction, iPosition:=1) clsPivotOperator.SetOperation("%>%") clsPivotOperator.AddParameter("left", clsRFunctionParameter:=clsPivotWiderFunction) @@ -492,6 +517,7 @@ Public Class dlgDescribeTwoVariable ucrBase.clsRsyntax.ClearCodes() ucrBase.clsRsyntax.SetBaseROperator(clsGroupByPipeOperator) + ThreeVarSummariesVar() bResetSubdialog = True End Sub @@ -505,6 +531,8 @@ Public Class dlgDescribeTwoVariable ucrChkLevSig.AddAdditionalCodeParameterPair(clsRAnovaSwapTable2Funtion, New RParameter("sign_level", iNewPosition:=4), iAdditionalPairNo:=1) ucrChkDisplayMargins.AddAdditionalCodeParameterPair(clsCombineFrequencyColParametersFunction, New RParameter("include_margins", iNewPosition:=5), iAdditionalPairNo:=1) ucrChkDisplayAsPercentage.AddAdditionalCodeParameterPair(clsCombineFrequencyColParametersFunction, New RParameter("percentage_type", iNewPosition:=1), iAdditionalPairNo:=1) + ucrChkDisplayMargins.AddAdditionalCodeParameterPair(clsThreeVariableCombineFrequencyParametersFunction, New RParameter("include_margins", iNewPosition:=5), iAdditionalPairNo:=2) + ucrChkInteraction.AddAdditionalCodeParameterPair(clsRAnovaSwapTable2Funtion, New RParameter("interaction", iNewPosition:=7), iAdditionalPairNo:=1) ucrSelectorDescribeTwoVar.AddAdditionalCodeParameterPair(clsSummaryTableFunction, ucrSelectorDescribeTwoVar.GetParameter(), iAdditionalPairNo:=1) ucrSaveTable.AddAdditionalRCode(clsJoiningPipeOperator, iAdditionalPairNo:=1) @@ -521,11 +549,11 @@ Public Class dlgDescribeTwoVariable ucrReceiverColumns.SetRCode(clsCombineFrequencyColParametersFunction, bReset) ucrPnlDescribe.SetRCode(clsDummyFunction, bReset) ucrpnlPercent.SetRCode(clsDummyFunction, bReset) - ucrChkSummariesRowCol.SetRCode(clsDummyFunction, bReset) ucrChkCorrelations.SetRCode(clsDummyFunction, bReset) ucrChkSwapXYVar.SetRCode(clsDummyFunction, bReset) ucrChkMeans.SetRCode(clsRAnovaTable2Function, bReset) ucrChkLevSig.SetRCode(clsRAnovaTable2Function, bReset) + ucrChkInteraction.SetRCode(clsRAnovaTable2Function, bReset) ucrReceiverThreeVariableSecondFactor.SetRCode(clsSummaryTableCombineFactorsFunction, bReset) ucrReceiverThreeVariableThirdVariable.SetRCode(clsSummaryTableCombineFactorsFunction, bReset) ucrChkDisplayMargins.SetRCode(clsCombineFrequencyParametersFunction, bReset) @@ -534,6 +562,9 @@ Public Class dlgDescribeTwoVariable FillListView() AddRemoveTotalParm() + AddInteraction() + ChangeBaseRCode() + ThreeVarSummariesVar() End Sub Public Sub TestOKEnabled() @@ -628,10 +659,12 @@ Public Class dlgDescribeTwoVariable Private Sub ManageControlsVisibility() grpSummaries.Visible = rdoThreeVariable.Checked OrElse rdoTwoVariable.Checked ucrChkDisplayMargins.Visible = rdoTwoVariable.Checked AndAlso IsFactorByFactor() - ucrInputMarginName.Visible = ucrChkDisplayMargins.Checked AndAlso IsFactorByFactor() + ucrChkDisplayMargins.Visible = rdoThreeVariable.Checked AndAlso IsFactorByFactorByNumeric() OrElse IsFactorByNumericByFactor() OrElse IsFactorByFactorByFactor() + ucrInputMarginName.Visible = ucrChkDisplayMargins.Checked AndAlso (IsFactorByFactor() OrElse IsFactorByFactorByNumeric() OrElse IsFactorByNumericByFactor()) + ucrInputMarginName.Visible = ucrChkDisplayMargins.Checked AndAlso IsFactorByFactorByNumeric() OrElse IsFactorByNumericByFactor() OrElse IsFactorByFactorByFactor() grpDisplay.Visible = rdoTwoVariable.Checked AndAlso IsFactorByFactor() ucrReceiverPercentages.Visible = ucrChkDisplayAsPercentage.Checked AndAlso rdoORow.Checked AndAlso IsFactorByFactor() - ucrpnlPercent.Visible = IsFactorByFactor() AndAlso ucrChkDisplayAsPercentage.Checked + ucrpnlPercent.Visible = rdoTwoVariable.Checked AndAlso IsFactorByFactor() AndAlso ucrChkDisplayAsPercentage.Checked ucrReceiverColumns.Visible = ucrChkDisplayAsPercentage.Checked AndAlso IsFactorByFactor() AndAlso rdoOCol.Checked ucrChkCorrelations.Visible = False ucrChkSwapXYVar.Visible = False @@ -639,10 +672,11 @@ Public Class dlgDescribeTwoVariable cmdMissingOptions.Visible = False If rdoTwoVariable.Checked Then - ucrChkOmitMissing.Visible = IsNumericByNumeric() OrElse IsNumericByFactor() + ucrChkOmitMissing.Visible = False + ucrChkOmitMissing.Visible = Not ucrChkSwapXYVar.Checked AndAlso IsFactorByNumeric() ucrChkSwapXYVar.Visible = IsNumericByNumeric() OrElse IsFactorByNumeric() ucrChkCorrelations.Visible = IsNumericByNumeric() - cmdMissingOptions.Visible = ucrChkOmitMissing.Checked + cmdMissingOptions.Visible = ucrChkOmitMissing.Checked AndAlso ucrChkOmitMissing.Visible End If If rdoThreeVariable.Checked Then If IsFactorByFactorByNumeric() OrElse IsFactorByNumericByFactor() Then @@ -652,9 +686,8 @@ Public Class dlgDescribeTwoVariable ucrReorderSummary.Visible = False cmdSummaries.Visible = False End If - ucrChkSwapXYVar.Visible = IsNumericByNumericByNumeric() OrElse IsNumericByNumericByFactor() - ucrChkSummariesRowCol.Visible = IsFactorByFactorByNumeric() OrElse IsFactorByNumericByFactor() - ucrChkOmitMissing.Visible = IsFactorByNumericByNumeric() OrElse IsNumericByNumericByFactor() + ucrChkOmitMissing.Visible = IsFactorByNumericByFactor() OrElse IsFactorByFactorByNumeric() + cmdMissingOptions.Visible = ucrChkOmitMissing.Checked End If End Sub @@ -662,12 +695,13 @@ Public Class dlgDescribeTwoVariable ucrSaveTable.Visible = False ucrReorderSummary.Visible = False cmdSummaries.Visible = False - ucrChkSummariesRowCol.Visible = False cmdFormatTable.Visible = False ucrChkMeans.Visible = False ucrChkLevSig.Visible = False ucrChkTotal.Visible = False + ucrChkInteraction.Visible = False cmdMissingOptions.Visible = False + ucrChkOmitMissing.Visible = False If rdoSkim.Checked Then clsDummyFunction.AddParameter("checked", "skim", iPosition:=0) cmdFormatTable.Visible = False @@ -685,12 +719,12 @@ Public Class dlgDescribeTwoVariable strObjectName:="last_summary") ElseIf rdoTwoVariable.Checked Then + ucrChkOmitMissing.Visible = False clsDummyFunction.AddParameter("checked", "customize", iPosition:=0) If IsNumericByNumeric() Then If ucrChkSwapXYVar.Checked Then ucrBase.clsRsyntax.SetBaseRFunction(clsMapping2Function) clsDummyFunction.AddParameter("var", "True", iPosition:=5) - Else ucrBase.clsRsyntax.SetBaseRFunction(clsMappingFunction) clsDummyFunction.AddParameter("var", "False", iPosition:=5) @@ -705,16 +739,25 @@ Public Class dlgDescribeTwoVariable End If ucrSaveTable.Visible = False cmdFormatTable.Visible = False + ucrChkInteraction.Visible = False ucrChkMeans.Visible = True ucrChkLevSig.Visible = True ucrChkTotal.Visible = True + ucrChkTotal.Location = New Point(310, 189) + ucrChkLevSig.Location = New Point(397, 186) + ucrChkMeans.Location = New Point(310, 210) + ElseIf IsNumericByFactor() Then ucrBase.clsRsyntax.SetBaseRFunction(clsMappingFunction) + ucrChkInteraction.Visible = False ucrChkMeans.Visible = True ucrChkLevSig.Visible = True ucrChkTotal.Visible = True ucrSaveTable.Visible = True ucrSaveTable.Location = New Point(23, 450) + ucrChkTotal.Location = New Point(310, 189) + ucrChkMeans.Location = New Point(310, 210) + ucrChkLevSig.Location = New Point(397, 186) clsDummyFunction.AddParameter("factor_cols", "Sum", iPosition:=1) ucrSaveTable.SetPrefix("summary_table") ucrSaveTable.SetSaveType(RObjectTypeLabel.Table, strRObjectFormat:=RObjectFormat.Html) @@ -727,7 +770,8 @@ Public Class dlgDescribeTwoVariable ucrChkMeans.Visible = False ucrChkLevSig.Visible = False ucrChkTotal.Visible = False - ucrSaveTable.Location = New Point(23, 351) + ucrChkInteraction.Visible = False + ucrSaveTable.Location = New Point(23, 370) clsDummyFunction.AddParameter("factor_cols", "FactorVar", iPosition:=1) ucrBase.clsRsyntax.SetBaseROperator(clsJoiningPipeOperator) ucrSaveTable.SetPrefix("frequency_table") @@ -747,22 +791,30 @@ Public Class dlgDescribeTwoVariable clsDummyFunction.AddParameter("var", "True", iPosition:=5) ucrReorderSummary.Visible = False cmdSummaries.Visible = False - ucrChkSummariesRowCol.Visible = False cmdFormatTable.Visible = False + ucrChkInteraction.Visible = False + ucrChkOmitMissing.Visible = False + cmdMissingOptions.Visible = False ucrChkMeans.Visible = True ucrChkLevSig.Visible = True ucrChkTotal.Visible = True + ucrChkTotal.Location = New Point(310, 189) + ucrChkLevSig.Location = New Point(397, 186) + ucrChkMeans.Location = New Point(310, 210) Else clsDummyFunction.AddParameter("var", "False", iPosition:=5) ucrSaveTable.Visible = True ucrReorderSummary.Visible = True cmdSummaries.Visible = True - ucrChkSummariesRowCol.Visible = True cmdFormatTable.Visible = True + ucrChkOmitMissing.Visible = True ucrChkMeans.Visible = False ucrChkLevSig.Visible = False ucrChkTotal.Visible = False + ucrChkInteraction.Visible = False ucrSaveTable.Location = New Point(23, 450) + ucrChkOmitMissing.Location = New Point(15, 365) + cmdMissingOptions.Location = New Point(17, 385) clsDummyFunction.AddParameter("factor_cols", "Sum", iPosition:=1) ucrBase.clsRsyntax.SetBaseROperator(clsJoiningPipeOperator) ucrSaveTable.SetPrefix("summary_table") @@ -779,7 +831,9 @@ Public Class dlgDescribeTwoVariable End If ElseIf rdoThreeVariable.Checked Then clsDummyFunction.AddParameter("checked", "three_variable", iPosition:=0) - + ucrBase.clsRsyntax.RemoveFromBeforeCodes(clsSummariesOperator) + ucrBase.clsRsyntax.RemoveFromBeforeCodes(clsFactorOperator) + ucrBase.clsRsyntax.RemoveFromBeforeCodes(clsCrossDfFunction) If IsFactorByFactorByFactor() Then cmdFormatTable.Visible = True ucrSaveTable.Location = New Point(23, 341) @@ -802,18 +856,24 @@ Public Class dlgDescribeTwoVariable ucrSaveTable.SetSaveType(RObjectTypeLabel.Table, strRObjectFormat:=RObjectFormat.Html) ucrSaveTable.SetAssignToIfUncheckedValue("last_table") ucrSaveTable.SetCheckBoxText("Store Cor") - ucrBase.clsRsyntax.SetBaseROperator(clsGroupByPipeOperator4) - clsGroupByPipeOperator4.SetAssignToOutputObject(strRObjectToAssignTo:="last_table", + ucrBase.clsRsyntax.SetBaseROperator(clsJoiningPipeOperator) + clsJoiningPipeOperator.SetAssignToOutputObject(strRObjectToAssignTo:="last_table", strRObjectTypeLabelToAssignTo:=RObjectTypeLabel.Table, strRObjectFormatToAssignTo:=RObjectFormat.Html, strRDataFrameNameToAddObjectTo:=ucrSelectorDescribeTwoVar.strCurrentDataFrame, strObjectName:="last_table") + ElseIf IsNumericByNumericByFactor() Then cmdFormatTable.Visible = False ucrSaveTable.Visible = False ucrChkMeans.Visible = True ucrChkLevSig.Visible = True ucrChkTotal.Visible = True + ucrChkInteraction.Visible = True + ucrChkTotal.Location = New Point(310, 250) + ucrChkLevSig.Location = New Point(397, 250) + ucrChkInteraction.Location = New Point(310, 275) + ucrChkMeans.Location = New Point(310, 300) If ucrChkSwapXYVar.Checked Then ucrBase.clsRsyntax.SetBaseRFunction(clsMapping2Function) clsDummyFunction.AddParameter("var", "True", iPosition:=5) @@ -824,20 +884,47 @@ Public Class dlgDescribeTwoVariable ElseIf IsNumericByNumericByNumeric() Then cmdFormatTable.Visible = False ucrSaveTable.Visible = False + ucrChkMeans.Visible = True + ucrChkLevSig.Visible = True + ucrChkTotal.Visible = True + ucrChkInteraction.Visible = True + ucrChkTotal.Location = New Point(310, 250) + ucrChkLevSig.Location = New Point(397, 250) + ucrChkInteraction.Location = New Point(310, 275) + ucrChkMeans.Location = New Point(310, 300) ucrBase.clsRsyntax.SetBaseRFunction(clsMappingFunction) ElseIf IsNumericByFactorByFactor() Then cmdFormatTable.Visible = False ucrSaveTable.Visible = False + ucrChkMeans.Visible = True + ucrChkLevSig.Visible = True + ucrChkTotal.Visible = True + ucrChkInteraction.Visible = True + ucrChkTotal.Location = New Point(310, 250) + ucrChkLevSig.Location = New Point(397, 250) + ucrChkInteraction.Location = New Point(310, 275) + ucrChkMeans.Location = New Point(310, 300) ucrBase.clsRsyntax.SetBaseRFunction(clsMappingFunction) ElseIf IsNumericByFactorByNumeric() Then cmdFormatTable.Visible = False ucrSaveTable.Visible = False + ucrChkMeans.Visible = True + ucrChkLevSig.Visible = True + ucrChkTotal.Visible = True + ucrChkInteraction.Visible = True + ucrChkTotal.Location = New Point(310, 250) + ucrChkLevSig.Location = New Point(397, 250) + ucrChkInteraction.Location = New Point(310, 275) + ucrChkMeans.Location = New Point(310, 300) ucrBase.clsRsyntax.SetBaseRFunction(clsMappingFunction) ElseIf IsFactorByNumericByFactor() OrElse IsFactorByFactorByNumeric() Then ucrSaveTable.SetPrefix("summary_table") ucrSaveTable.SetSaveType(RObjectTypeLabel.Table, strRObjectFormat:=RObjectFormat.Html) ucrSaveTable.SetAssignToIfUncheckedValue("last_table") ucrSaveTable.SetCheckBoxText("Save Table") + ucrBase.clsRsyntax.AddToBeforeCodes(clsSummariesOperator, 0) + ucrBase.clsRsyntax.AddToBeforeCodes(clsFactorOperator, 1) + ucrBase.clsRsyntax.AddToBeforeCodes(clsCrossDfFunction, 2) ucrBase.clsRsyntax.SetBaseROperator(clsJoiningPipeOperator) clsJoiningPipeOperator.SetAssignToOutputObject(strRObjectToAssignTo:="last_table", strRObjectTypeLabelToAssignTo:=RObjectTypeLabel.Table, @@ -847,11 +934,17 @@ Public Class dlgDescribeTwoVariable ucrReorderSummary.Visible = True cmdSummaries.Visible = True ucrSaveTable.Visible = True - ucrChkSummariesRowCol.Visible = True + ucrChkOmitMissing.Visible = True ucrSaveTable.Location = New Point(23, 440) + ucrChkOmitMissing.Location = New Point(15, 360) + cmdMissingOptions.Location = New Point(17, 380) End If End If FactorColumns() + AddInteraction() + AddRemoveSecondAnovaParam() + AddRemoveThirdCorrParam() + ThreeVarSummariesVar() End Sub Private Sub UpdateCombineFactorParameterFunction() @@ -864,11 +957,11 @@ Public Class dlgDescribeTwoVariable clsSummaryTableFunction.RemoveParameterByName("na.rm") If ucrChkOmitMissing.Checked Then If rdoTwoVariable.Checked Then - If IsNumericByFactor() Then + If Not ucrChkSwapXYVar.Checked AndAlso IsFactorByNumeric() Then clsSummaryTableFunction.AddParameter("na.rm", "TRUE", iPosition:=5) End If ElseIf rdoThreeVariable.Checked Then - If IsNumericByFactor() OrElse IsFactorByNumeric() Then + If IsFactorByFactorByNumeric() OrElse IsFactorByNumericByFactor() Then clsSummaryTableFunction.AddParameter("na.rm", "TRUE", iPosition:=5) End If End If @@ -894,11 +987,15 @@ Public Class dlgDescribeTwoVariable clsSummaryTableFunction.AddParameter("na_type", clsRFunctionParameter:=clsCombineFunction, iPosition:=9) End If cmdMissingOptions.Visible = ucrChkOmitMissing.Checked - + ManageControlsVisibility() + ChangeBaseRCode() End Sub Private Sub ucrPnlDescribe_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrPnlDescribe.ControlValueChanged ucrReceiverFirstVars.Clear() + ucrReceiverThreeVariableSecondFactor.Clear() + ucrReceiverThreeVariableThirdVariable.Clear() + ucrReceiverSecondTwoVariableFactor.Clear() ucrReceiverFirstVars.SetMeAsReceiver() If rdoSkim.Checked Then @@ -933,6 +1030,7 @@ Public Class dlgDescribeTwoVariable AddRemoveSecondAnovaParam() AddRemoveThirdAnovaParam() AddRemoveFirstAnova2Param() + ThreeVarSummariesVar() End Sub Private Sub ChangeLocations() @@ -951,8 +1049,8 @@ Public Class dlgDescribeTwoVariable ucrBase.Location = New Point(iUcrBaseXLocation, 319) Me.Size = New Point(iDialogueXsize, 415) ElseIf IsFactorByFactor() Then - ucrBase.Location = New Point(iUcrBaseXLocation, 372) - Me.Size = New Point(iDialogueXsize, 465) + ucrBase.Location = New Point(iUcrBaseXLocation, 392) + Me.Size = New Point(iDialogueXsize, 485) cmdFormatTable.Location = New Point(326, 330) Else ucrBase.Location = New Point(iUcrBaseXLocation, 328) @@ -962,7 +1060,6 @@ Public Class dlgDescribeTwoVariable If IsNumericByNumericByFactor() OrElse IsNumericByNumericByNumeric() OrElse IsNumericByFactorByFactor() OrElse IsNumericByFactorByNumeric() Then ucrBase.Location = New Point(iUcrBaseXLocation, 353) - ucrChkSwapXYVar.Location = New Point(300, 320) Me.Size = New Point(iDialogueXsize, 450) ElseIf IsFactorByFactorByFactor() Then ucrBase.Location = New Point(iUcrBaseXLocation, 370) @@ -978,8 +1075,8 @@ Public Class dlgDescribeTwoVariable End If Else - ucrBase.Location = New Point(iUcrBaseXLocation, 328) - Me.Size = New Point(iDialogueXsize, 425) + ucrBase.Location = New Point(iUcrBaseXLocation, 333) + Me.Size = New Point(iDialogueXsize, 430) End If End Sub @@ -1023,10 +1120,12 @@ Public Class dlgDescribeTwoVariable If rdoThreeVariable.Checked Then If IsFactorByNumericByNumeric() Then If ucrReceiverThreeVariableThirdVariable.IsEmpty Then - clsCorrFunction.RemoveParameterByName("y") + clsSummaryTableFunction.RemoveParameterByName("y") Else - clsCorrFunction.AddParameter("y", ucrReceiverThreeVariableThirdVariable.GetVariableNames(False), iPosition:=2, bIncludeArgumentName:=False) + clsSummaryTableFunction.AddParameter("y", ucrReceiverThreeVariableThirdVariable.GetVariableNames) End If + Else + clsSummaryTableFunction.RemoveParameterByName("y") End If End If End Sub @@ -1042,36 +1141,75 @@ Public Class dlgDescribeTwoVariable clsPivotWiderFunction.AddParameter("names_from", "{{ .x }}", iPosition:=1) clsSummaryTableFunction.AddParameter("columns_to_summarise", ucrReceiverSecondTwoVariableFactor.GetVariableNames) clsMapSummaryFunction.AddParameter(".x", ucrReceiverFirstVars.GetVariableNames, iPosition:=3) - SummariesInRowsOrCols() Else clsSummaryTableFunction.AddParameter("factors", ucrReceiverSecondTwoVariableFactor.GetVariableNames) clsPivotWiderFunction.AddParameter("names_from", Chr(39) & "summary-variable" & Chr(39), iPosition:=1) clsSummaryTableFunction.AddParameter("columns_to_summarise", ucrReceiverFirstVars.GetVariableNames) - SummariesInRowsOrCols() End If End If If rdoThreeVariable.Checked Then - clsSummaryOperator.AddParameter("col_factor", clsRFunctionParameter:=clsPivotWiderFunction, iPosition:=1) If IsFactorByFactorByFactor() Then clsSummaryTableFunction.AddParameter("factors", "c(" & ucrReceiverThreeVariableSecondFactor.GetVariableNames & "," & ucrReceiverThreeVariableThirdVariable.GetVariableNames & "," & ".x" & ")") clsSummaryTableFunction.AddParameter("columns_to_summarise", ".x") - clsPivotWiderFunction.AddParameter("names_from", "{{ .x }}", iPosition:=1) + clsPivotWiderFunction.AddParameter("names_from", ucrReceiverThreeVariableThirdVariable.GetVariableNames(False), iPosition:=0) + clsSummaryOperator.AddParameter("col_factor", clsRFunctionParameter:=clsPivotWiderFunction, iPosition:=1) ElseIf IsFactorByFactorByNumeric() Then - clsMapSummaryFunction.AddParameter(".x", "c(" & ucrReceiverFirstVars.GetVariableNames.Replace("c(", "").Replace(")", "") & "," & ucrReceiverThreeVariableSecondFactor.GetVariableNames.Replace("c(", "").Replace(")", "") & ")") - clsSummaryTableFunction.AddParameter("factors", ".x") + clsSummaryTableFunction.AddParameter("factors", "c(" & ".x" & "," & ucrReceiverThreeVariableSecondFactor.GetVariableNames & ")") clsSummaryTableFunction.AddParameter("columns_to_summarise", ucrReceiverThreeVariableThirdVariable.GetVariableNames) - SummariesInRowsOrCols() + clsSummaryTableFunction.AddParameter("summaries", ".y", iPosition:=0) + clsPivotWiderFunction.AddParameter("names_from", ucrReceiverThreeVariableSecondFactor.GetVariableNames(False), iPosition:=0) + clsSummaryOperator.RemoveParameterByName("col_factor") ElseIf IsFactorByNumericByFactor() Then - clsMapSummaryFunction.AddParameter(".x", "c(" & ucrReceiverFirstVars.GetVariableNames.Replace("c(", "").Replace(")", "") & "," & ucrReceiverThreeVariableThirdVariable.GetVariableNames.Replace("c(", "").Replace(")", "") & ")") - clsSummaryTableFunction.AddParameter("factors", ".x") + clsSummaryTableFunction.AddParameter("factors", "c(" & ".x" & "," & ucrReceiverThreeVariableThirdVariable.GetVariableNames & ")") clsSummaryTableFunction.AddParameter("columns_to_summarise", ucrReceiverThreeVariableSecondFactor.GetVariableNames) - SummariesInRowsOrCols() + clsSummaryTableFunction.AddParameter("summaries", ".y", iPosition:=0) + clsSummaryOperator.RemoveParameterByName("col_factor") + clsPivotWiderFunction.AddParameter("names_from", ucrReceiverThreeVariableThirdVariable.GetVariableNames(False), iPosition:=0) + + ElseIf IsFactorByNumericByNumeric() Then + clsMapSummaryFunction.AddParameter(".x", ucrReceiverFirstVars.GetVariableNames) + clsPivotWiderFunction.AddParameter("names_from", Chr(39) & "summary-variable" & Chr(39), iPosition:=0) + clsSummaryTableFunction.AddParameter("columns_to_summarise", ucrReceiverThreeVariableSecondFactor.GetVariableNames) + clsSummaryTableFunction.AddParameter("summaries", Chr(34) & "summary_cor" & Chr(34), iPosition:=0) + clsSummaryTableFunction.AddParameter("factors", ".x") + clsSummaryOperator.AddParameter("col_factor", clsRFunctionParameter:=clsPivotWiderFunction, iPosition:=1) Else clsPivotWiderFunction.AddParameter("names_from", Chr(39) & "summary-variable" & Chr(39), iPosition:=0) clsSummaryTableFunction.AddParameter("columns_to_summarise", ucrReceiverFirstVars.GetVariableNames) - SummariesInRowsOrCols() + clsSummaryOperator.AddParameter("col_factor", clsRFunctionParameter:=clsPivotWiderFunction, iPosition:=1) End If End If + ThreeVarSummariesVar() + End Sub + + Private Sub ThreeVarSummariesVar() + clsMap2SummaryFunction.RemoveParameterByName(".f") + clsMapSummaryFunction.RemoveParameterByName(".f") + clsSummaryOperator.RemoveParameterByName("right") + clsSummaryOperator.RemoveParameterByName("tableFun") + If rdoThreeVariable.Checked Then + If IsFactorByNumericByFactor() OrElse IsFactorByFactorByNumeric() Then + clsFactorOperator.AddParameter("factors", ucrReceiverFirstVars.GetVariableNames, iPosition:=0, bIncludeArgumentName:=False) + clsSummariesOperator.AddParameter("summary", clsRFunctionParameter:=clsSummariesListFunction, iPosition:=0, bIncludeArgumentName:=False) + clsMap2SummaryFunction.AddParameter(".f", clsROperatorParameter:=clsMapOperator, iPosition:=2) + clsSummaryOperator.AddParameter("right", clsRFunctionParameter:=clsMap2SummaryFunction, iPosition:=2) + + ElseIf IsFactorByNumericByNumeric() Then + clsMapSummaryFunction.AddParameter(".f", clsROperatorParameter:=clsMapOperator, iPosition:=1) + clsSummaryOperator.AddParameter("tableFun", clsRFunctionParameter:=clsMapSummaryFunction, iPosition:=2) + + ElseIf IsFactorByNumericByNumeric() Then + clsMapSummaryFunction.AddParameter(".f", clsROperatorParameter:=clsMapOperator, iPosition:=1) + clsSummaryOperator.AddParameter("tableFun", clsRFunctionParameter:=clsMapSummaryFunction, iPosition:=2) + + ElseIf IsFactorByFactorByFactor() Then + clsMapSummaryFunction.AddParameter(".f", clsROperatorParameter:=clsMapOperator, iPosition:=1) + clsSummaryOperator.AddParameter("tableFun", clsRFunctionParameter:=clsMapSummaryFunction, iPosition:=2) + End If + ElseIf rdoTwoVariable.Checked Then + clsMapSummaryFunction.AddParameter(".f", clsROperatorParameter:=clsMapOperator, iPosition:=1) + clsSummaryOperator.AddParameter("tableFun", clsRFunctionParameter:=clsMapSummaryFunction, iPosition:=2) + End If End Sub Private Sub AddRemoveFirstAnova2Param() @@ -1135,6 +1273,8 @@ Public Class dlgDescribeTwoVariable End Sub Private Sub AddRemoveSecondAnovaParam() + clsCombineSwapAnova2Table.RemoveParameterByName("x") + clsCombineAnova2Function.RemoveParameterByName("x") If rdoThreeVariable.Checked Then If Not ucrReceiverThreeVariableSecondFactor.IsEmpty Then If IsNumericByNumericByFactor() Then @@ -1216,6 +1356,8 @@ Public Class dlgDescribeTwoVariable Else clsCombineAnova2Function.RemoveParameterByName("y") End If + Else + clsCombineAnova2Function.RemoveParameterByName("y") End If End Sub @@ -1262,10 +1404,25 @@ Public Class dlgDescribeTwoVariable End If Next End If + ElseIf rdoThreeVariable.Checked Then + + For Each clsParameter In clsTempFrequency.clsParameters + If IsFactorByFactorByFactor() Then + clsSummaryTableFunction.AddParameter(clsParameter) + Else + If IsFactorByFactorByNumeric() OrElse IsFactorByNumericByFactor() Then + Select Case clsParameter.strArgumentName + Case "signif_fig", "include_margins", "margin_name" + clsSummaryTableFunction.AddParameter(clsParameter) + End Select + End If + End If + Next + End If End Sub - Private Sub Frequencies_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverPercentages.ControlValueChanged, ucrReceiverColumns.ControlValueChanged, + Private Sub Frequencies_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverPercentages.ControlValueChanged, ucrChkDisplayAsPercentage.ControlValueChanged, ucrChkDisplayMargins.ControlValueChanged, ucrInputMarginName.ControlValueChanged, ucrpnlPercent.ControlValueChanged If rdoTwoVariable.Checked Then If ucrChkDisplayAsPercentage.Checked Then @@ -1303,7 +1460,16 @@ Public Class dlgDescribeTwoVariable clsCombineFrequencyColParametersFunction.RemoveParameterByName("margin_name") clsCombineFrequencyParametersFunction.RemoveParameterByName("margin_name") End If + If rdoThreeVariable.Checked AndAlso IsFactorByFactorByFactor() OrElse IsFactorByFactorByNumeric() OrElse IsFactorByNumericByFactor() Then + If ucrChkDisplayMargins.Checked Then + ucrInputMarginName.Visible = True + clsThreeVariableCombineFrequencyParametersFunction.AddParameter("margin_name", Chr(34) & ucrInputMarginName.GetText & Chr(34), iPosition:=6) + Else + ucrInputMarginName.Visible = False + clsThreeVariableCombineFrequencyParametersFunction.RemoveParameterByName("margin_name") + End If + End If FactorColumns() AddRemoveFrequencyParameters() AddingColumnFactor() @@ -1426,17 +1592,6 @@ Public Class dlgDescribeTwoVariable ManageControlsVisibility() End Sub - Private Sub SummariesInRowsOrCols() - If ucrChkSummariesRowCol.Checked Then - clsPivotWiderFunction.AddParameter("names_from", "{{ .x }}", iPosition:=1) - clsDummyFunction.AddParameter("row_sum", "True", iPosition:=3) - Else - clsPivotWiderFunction.AddParameter("names_from", Chr(39) & "summary-variable" & Chr(39), iPosition:=1) - clsDummyFunction.AddParameter("row_sum", "False", iPosition:=3) - End If - ManageControlsVisibility() - End Sub - Private Sub ucrReceiverSecondTwoVariableFactor_ValueAndContentChanged(ucrChangedControl As ucrCore) Handles ucrReceiverSecondTwoVariableFactor.ControlValueChanged, ucrReceiverSecondTwoVariableFactor.ControlContentsChanged AssignSecondVariableType() @@ -1449,6 +1604,7 @@ Public Class dlgDescribeTwoVariable AddRemoveFirstAnova2Param() AddRemoveSecondAnovaParam() AddingColumnFactor() + AddRemoveThirdAnovaParam() End Sub Private Sub ChangeFirstTypeLabel() @@ -1524,6 +1680,7 @@ Public Class dlgDescribeTwoVariable AddRemoveThirdAnovaParam() AddRemoveFirstAnova2Param() AddingColumnFactor() + ThreeVarSummariesVar() End Sub Private Sub ucrReceiverThreeVariableSecondFactor_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverThreeVariableSecondFactor.ControlValueChanged @@ -1533,6 +1690,7 @@ Public Class dlgDescribeTwoVariable AddRemoveSecondCorrParam() AddRemoveSecondAnovaParam() AddRemoveFirstAnova2Param() + UpdateSummaryTableFunction() FactorColumns() ChangeLocations() ChangeSumaryLabelText() @@ -1659,14 +1817,13 @@ Public Class dlgDescribeTwoVariable Next End Sub - Private Sub ucrChkSummariesRowCol_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkSummariesRowCol.ControlValueChanged - ManageControlsVisibility() - SummariesInRowsOrCols() - ChangeBaseRCode() - End Sub - Private Sub ucrChkCorrelations_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkCorrelations.ControlValueChanged ChangeBaseRCode() + If ucrChkCorrelations.Checked AndAlso Not ucrReceiverFirstVars.IsEmpty Then + clsRCorrelationFunction.AddParameter("x_col_names", ucrReceiverFirstVars.GetVariableNames) + Else + clsRCorrelationFunction.RemoveParameterByName("x_col_names") + End If End Sub Private Sub ucrChkSwapXYVar_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkSwapXYVar.ControlValueChanged @@ -1734,6 +1891,19 @@ Public Class dlgDescribeTwoVariable Private Sub AddRemoveTotalParm() clsRAnovaTable2Function.AddParameter("total", If(ucrChkTotal.Checked, "TRUE", "FALSE"), iPosition:=6) clsRAnovaSwapTable2Funtion.AddParameter("total", If(ucrChkTotal.Checked AndAlso ucrChkSwapXYVar.Checked, "TRUE", "FALSE"), iPosition:=6) + End Sub + + Private Sub ucrChkInteraction_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkInteraction.ControlValueChanged + AddInteraction() + End Sub + Private Sub AddInteraction() + If rdoThreeVariable.Checked AndAlso ucrChkInteraction.Checked Then + clsRAnovaTable2Function.AddParameter("interaction", "TRUE", iPosition:=7) + clsRAnovaSwapTable2Funtion.AddParameter("interaction", "TRUE", iPosition:=7) + Else + clsRAnovaTable2Function.RemoveParameterByName("interaction") + clsRAnovaSwapTable2Funtion.RemoveParameterByName("interaction") + End If End Sub End Class diff --git a/instat/dlgDisplayDailyData.vb b/instat/dlgDisplayDailyData.vb index c4cb6d97038..93808123a65 100644 --- a/instat/dlgDisplayDailyData.vb +++ b/instat/dlgDisplayDailyData.vb @@ -156,7 +156,7 @@ Public Class dlgDisplayDailyData ucrChkIQR.SetParameter(New RParameter("IQR", 5), bNewChangeParameterValue:=True, bNewAddRemoveParameter:=True, strNewValueIfChecked:=Chr(34) & "IQR" & Chr(34), strNewValueIfUnchecked:=Chr(34) & Chr(34)) ucrChkIQR.SetText("IQR") - ucrChkSumMissing.SetParameter(New RParameter("summary_count_missing", 6), bNewChangeParameterValue:=True, bNewAddRemoveParameter:=True, strNewValueIfChecked:=Chr(34) & "summary_count_missing" & Chr(34), strNewValueIfUnchecked:=Chr(34) & Chr(34)) + ucrChkSumMissing.SetParameter(New RParameter("summary_count_miss", 6), bNewChangeParameterValue:=True, bNewAddRemoveParameter:=True, strNewValueIfChecked:=Chr(34) & "summary_count_miss" & Chr(34), strNewValueIfUnchecked:=Chr(34) & Chr(34)) ucrChkSumMissing.SetText("N Missing") ucrNudNumberOfColumns.SetParameter(New RParameter("ncol", 1)) diff --git a/instat/dlgExtremesClimatic.vb b/instat/dlgExtremesClimatic.vb index 6c6052c193c..06d745e640b 100644 --- a/instat/dlgExtremesClimatic.vb +++ b/instat/dlgExtremesClimatic.vb @@ -447,7 +447,7 @@ Public Class dlgExtremesClimatic clsNSummary.AddParameter("save", "2", iPosition:=4) clsNSummary.SetAssignTo("n_dates_summary") - clsNFunction.SetRCommand("summary_count") + clsNFunction.SetRCommand("summary_count_all") clsNFunction.bToScriptAsRString = True clsFilterExtremeCalc.SetRCommand("instat_calculation$new") diff --git a/instat/dlgLabelsLevels.vb b/instat/dlgLabelsLevels.vb index c3eac2d5c01..a83bc95ce56 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) diff --git a/instat/dlgName.vb b/instat/dlgName.vb index 8d049242001..b108de0f7ea 100644 --- a/instat/dlgName.vb +++ b/instat/dlgName.vb @@ -145,7 +145,7 @@ Public Class dlgName ucrPnlOptions.AddToLinkedControls({ucrPnlCase, ucrPnlSelectData}, {rdoRenameWith}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrPnlCase.AddToLinkedControls(ucrInputCase, {rdoMakeCleanNames}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="Snake") ucrPnlCase.AddToLinkedControls(ucrNudAbbreviate, {rdoAbbreviate}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="8") - ucrPnlCase.AddToLinkedControls(ucrInputReplace, {rdoReplace}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) + ucrPnlCase.AddToLinkedControls(ucrInputReplace, {rdoReplace}, bNewLinkedHideIfParameterMissing:=True) ucrPnlCase.AddToLinkedControls(ucrInputBy, {rdoReplace}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="") ucrPnlCase.AddToLinkedControls(ucrInputEdit, {rdoReplace}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True, bNewLinkedChangeToDefaultState:=True, objNewDefaultState:="Starts With") ucrPnlSelectData.AddToLinkedControls(ucrReceiverColumns, {rdoSelectedColumn}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) @@ -660,21 +660,23 @@ Public Class dlgName Private Sub RemovePattern() If rdoWholeDataFrame.Checked Then - If rdoReplace.Checked Then + If rdoRenameWith.Checked AndAlso rdoReplace.Checked Then clsDefaultRFunction.AddParameter("type", Chr(34) & "rename_with" & Chr(34), iPosition:=1) clsDefaultRFunction.AddParameter(".fn", "stringr::str_replace", iPosition:=2) clsDefaultRFunction.AddParameter("pattern", Chr(34) & ucrInputReplace.GetText() & Chr(34), iPosition:=4) clsDefaultRFunction.RemoveParameterByName("label") clsDefaultRFunction.AddParameter("replacement", Chr(34) & ucrInputBy.GetText() & Chr(34), iPosition:=5) - If ucrInputEdit.GetText = "Starts With" Then - clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsStartwithFunction, iPosition:=3) - ElseIf ucrInputEdit.GetText = "Ends With" Then - clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsEndswithFunction, iPosition:=3) - ElseIf ucrInputEdit.GetText = "Matches" Then - clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsMatchesFunction, iPosition:=3) - ElseIf ucrInputEdit.GetText = "Contains" Then - clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsContainsFunction, iPosition:=3) - End If + + Select Case ucrInputEdit.GetText + Case "Starts With" + clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsStartwithFunction, iPosition:=3) + Case "Ends With" + clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsEndswithFunction, iPosition:=3) + Case "Matches" + clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsMatchesFunction, iPosition:=3) + Case "Contains" + clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsContainsFunction, iPosition:=3) + End Select Else clsDefaultRFunction.RemoveParameterByName("pattern") clsDefaultRFunction.RemoveParameterByName("replacement") diff --git a/instat/dlgOneVariableSummarise.vb b/instat/dlgOneVariableSummarise.vb index 1726ec12348..c973af6015f 100644 --- a/instat/dlgOneVariableSummarise.vb +++ b/instat/dlgOneVariableSummarise.vb @@ -248,8 +248,8 @@ Public Class dlgOneVariableSummarise strObjectName:="last_table") clsSummariesList.SetRCommand("c") - clsSummariesList.AddParameter("summary_count_non_missing", Chr(34) & "summary_count_non_missing" & Chr(34), bIncludeArgumentName:=False) clsSummariesList.AddParameter("summary_count", Chr(34) & "summary_count" & Chr(34), bIncludeArgumentName:=False) + clsSummariesList.AddParameter("summary_count_all", Chr(34) & "summary_count_all" & Chr(34), bIncludeArgumentName:=False) clsSummariesList.AddParameter("summary_sum", Chr(34) & "summary_sum" & Chr(34), bIncludeArgumentName:=False) clsSummaryFunction.SetRCommand("summary") diff --git a/instat/dlgSummaryTables.Designer.vb b/instat/dlgSummaryTables.Designer.vb index dc580406db6..62161275db2 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 909a040bf87..5239070065f 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() diff --git a/instat/frmMain.Designer.vb b/instat/frmMain.Designer.vb index daae5be1236..1ace18cf469 100644 --- a/instat/frmMain.Designer.vb +++ b/instat/frmMain.Designer.vb @@ -405,7 +405,9 @@ Partial Class frmMain Me.toolStripSeparator = New System.Windows.Forms.ToolStripSeparator() Me.mnuTbLast10Dialogs = New System.Windows.Forms.ToolStripSplitButton() Me.separator2 = New System.Windows.Forms.ToolStripSeparator() - Me.mnuTbDataView = New System.Windows.Forms.ToolStripButton() + Me.mnuTbDataView = New System.Windows.Forms.ToolStripSplitButton() + Me.mnuDataViewWindow = New System.Windows.Forms.ToolStripMenuItem() + Me.mnuRDataViewerWindow = New System.Windows.Forms.ToolStripMenuItem() Me.mnuTbOutput = New System.Windows.Forms.ToolStripSplitButton() Me.mnuOutputWindow = New System.Windows.Forms.ToolStripMenuItem() Me.mnuShowRCommand = New System.Windows.Forms.ToolStripMenuItem() @@ -426,7 +428,11 @@ Partial Class frmMain Me.ToolStripSeparator76 = New System.Windows.Forms.ToolStripSeparator() Me.mnuTbResetLayout = New System.Windows.Forms.ToolStripButton() Me.separator3 = New System.Windows.Forms.ToolStripSeparator() - Me.mnuTbHelp = New System.Windows.Forms.ToolStripButton() + Me.mnuTbHelp = New System.Windows.Forms.ToolStripSplitButton() + Me.mnuToolBarHelp = New System.Windows.Forms.ToolStripMenuItem() + Me.mnuDataWindowHelp = New System.Windows.Forms.ToolStripMenuItem() + Me.mnuOutputHelp = New System.Windows.Forms.ToolStripMenuItem() + Me.mnuLogScriptHelp = New System.Windows.Forms.ToolStripMenuItem() Me.ToolStripSeparator77 = New System.Windows.Forms.ToolStripSeparator() Me.mnuTbLan = New System.Windows.Forms.ToolStripButton() Me.separator1 = New System.Windows.Forms.ToolStripSeparator() @@ -3032,14 +3038,14 @@ Partial Class frmMain ' Me.mnuUndo.Name = "mnuUndo" Me.mnuUndo.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Z), System.Windows.Forms.Keys) - Me.mnuUndo.Size = New System.Drawing.Size(180, 22) + Me.mnuUndo.Size = New System.Drawing.Size(167, 22) Me.mnuUndo.Text = "Undo" ' 'mnuEditFind ' Me.mnuEditFind.Name = "mnuEditFind" Me.mnuEditFind.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.F), System.Windows.Forms.Keys) - Me.mnuEditFind.Size = New System.Drawing.Size(180, 22) + Me.mnuEditFind.Size = New System.Drawing.Size(167, 22) Me.mnuEditFind.Tag = "Find" Me.mnuEditFind.Text = "Find" ' @@ -3047,7 +3053,7 @@ Partial Class frmMain ' Me.mnuEditCopy.Name = "mnuEditCopy" Me.mnuEditCopy.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.C), System.Windows.Forms.Keys) - Me.mnuEditCopy.Size = New System.Drawing.Size(180, 22) + Me.mnuEditCopy.Size = New System.Drawing.Size(167, 22) Me.mnuEditCopy.Tag = "Copy" Me.mnuEditCopy.Text = "Copy" ' @@ -3055,27 +3061,27 @@ Partial Class frmMain ' Me.mnuEditPaste.Name = "mnuEditPaste" Me.mnuEditPaste.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.V), System.Windows.Forms.Keys) - Me.mnuEditPaste.Size = New System.Drawing.Size(180, 22) + Me.mnuEditPaste.Size = New System.Drawing.Size(167, 22) Me.mnuEditPaste.Tag = "Paste" Me.mnuEditPaste.Text = "Paste" ' 'mnuEditPasteNew ' Me.mnuEditPasteNew.Name = "mnuEditPasteNew" - Me.mnuEditPasteNew.Size = New System.Drawing.Size(180, 22) + Me.mnuEditPasteNew.Size = New System.Drawing.Size(167, 22) Me.mnuEditPasteNew.Text = "Paste New..." ' 'mnuEditWordwrap ' Me.mnuEditWordwrap.Name = "mnuEditWordwrap" - Me.mnuEditWordwrap.Size = New System.Drawing.Size(180, 22) + Me.mnuEditWordwrap.Size = New System.Drawing.Size(167, 22) Me.mnuEditWordwrap.Text = "Wordwrap..." ' 'mnuEditSelectAll ' Me.mnuEditSelectAll.Name = "mnuEditSelectAll" Me.mnuEditSelectAll.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.A), System.Windows.Forms.Keys) - Me.mnuEditSelectAll.Size = New System.Drawing.Size(180, 22) + Me.mnuEditSelectAll.Size = New System.Drawing.Size(167, 22) Me.mnuEditSelectAll.Tag = "Select_All" Me.mnuEditSelectAll.Text = "Select All " ' @@ -3195,15 +3201,31 @@ Partial Class frmMain ' 'mnuTbDataView ' - Me.mnuTbDataView.CheckOnClick = True Me.mnuTbDataView.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.mnuTbDataView.DropDownButtonWidth = 18 + Me.mnuTbDataView.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuDataViewWindow, Me.mnuRDataViewerWindow}) Me.mnuTbDataView.Image = Global.instat.My.Resources.Resources.dataframe2 Me.mnuTbDataView.ImageTransparentColor = System.Drawing.Color.Magenta Me.mnuTbDataView.Margin = New System.Windows.Forms.Padding(2, 1, 2, 2) Me.mnuTbDataView.Name = "mnuTbDataView" - Me.mnuTbDataView.Size = New System.Drawing.Size(34, 34) + Me.mnuTbDataView.Size = New System.Drawing.Size(53, 34) Me.mnuTbDataView.ToolTipText = "Toggle Data view open and closed" ' + 'mnuDataViewWindow + ' + Me.mnuDataViewWindow.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None + Me.mnuDataViewWindow.Name = "mnuDataViewWindow" + Me.mnuDataViewWindow.Size = New System.Drawing.Size(180, 22) + Me.mnuDataViewWindow.Text = "Data View" + ' + 'mnuRDataViewerWindow + ' + Me.mnuRDataViewerWindow.Enabled = False + Me.mnuRDataViewerWindow.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None + Me.mnuRDataViewerWindow.Name = "mnuRDataViewerWindow" + Me.mnuRDataViewerWindow.Size = New System.Drawing.Size(180, 22) + Me.mnuRDataViewerWindow.Text = "R-Data Viewer" + ' 'mnuTbOutput ' Me.mnuTbOutput.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image @@ -3359,12 +3381,40 @@ Partial Class frmMain 'mnuTbHelp ' Me.mnuTbHelp.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image + Me.mnuTbHelp.DropDownButtonWidth = 18 + Me.mnuTbHelp.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuToolBarHelp, Me.mnuDataWindowHelp, Me.mnuOutputHelp, Me.mnuLogScriptHelp}) Me.mnuTbHelp.Image = Global.instat.My.Resources.Resources.help2 Me.mnuTbHelp.ImageTransparentColor = System.Drawing.Color.Magenta - Me.mnuTbHelp.Margin = New System.Windows.Forms.Padding(2, 1, 2, 2) Me.mnuTbHelp.Name = "mnuTbHelp" - Me.mnuTbHelp.Size = New System.Drawing.Size(34, 34) - Me.mnuTbHelp.Text = "He&lp" + Me.mnuTbHelp.Size = New System.Drawing.Size(53, 34) + Me.mnuTbHelp.Text = "LogScript" + Me.mnuTbHelp.ToolTipText = "Help Window" + ' + 'mnuToolBarHelp + ' + Me.mnuToolBarHelp.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None + Me.mnuToolBarHelp.Name = "mnuToolBarHelp" + Me.mnuToolBarHelp.Size = New System.Drawing.Size(173, 22) + Me.mnuToolBarHelp.Text = "Toolbar Help" + ' + 'mnuDataWindowHelp + ' + Me.mnuDataWindowHelp.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None + Me.mnuDataWindowHelp.Name = "mnuDataWindowHelp" + Me.mnuDataWindowHelp.Size = New System.Drawing.Size(173, 22) + Me.mnuDataWindowHelp.Text = "Data Window Help" + ' + 'mnuOutputHelp + ' + Me.mnuOutputHelp.Name = "mnuOutputHelp" + Me.mnuOutputHelp.Size = New System.Drawing.Size(173, 22) + Me.mnuOutputHelp.Text = "Output Help" + ' + 'mnuLogScriptHelp + ' + Me.mnuLogScriptHelp.Name = "mnuLogScriptHelp" + Me.mnuLogScriptHelp.Size = New System.Drawing.Size(173, 22) + Me.mnuLogScriptHelp.Text = "Log Script Help" ' 'ToolStripSeparator77 ' @@ -5343,7 +5393,6 @@ Partial Class frmMain Friend WithEvents toolStripSeparator As ToolStripSeparator Friend WithEvents separator1 As ToolStripSeparator Friend WithEvents separator2 As ToolStripSeparator - Friend WithEvents mnuTbHelp As ToolStripButton Private WithEvents mnuBar As MenuStrip Friend WithEvents mnuFile As ToolStripMenuItem Friend WithEvents mnuFileNewDataFrame As ToolStripMenuItem @@ -5656,7 +5705,6 @@ Partial Class frmMain Friend WithEvents mnuClimaticCMSAFPlotRegion As ToolStripMenuItem Friend WithEvents mnuPrepareColumnDateInfillMissingDates As ToolStripMenuItem Friend WithEvents mnuTbOpenFromLibrary As ToolStripButton - Friend WithEvents mnuTbDataView As ToolStripButton Friend WithEvents separator3 As ToolStripSeparator Friend WithEvents mnuTbResetLayout As ToolStripButton Friend WithEvents mnuTbOpen As ToolStripSplitButton @@ -5981,4 +6029,12 @@ Partial Class frmMain Friend WithEvents ToolStripSeparator15 As ToolStripSeparator Friend WithEvents mnuClimaticCheckDataDistances As ToolStripMenuItem Friend WithEvents mnuUndo As ToolStripMenuItem + Friend WithEvents mnuTbHelp As ToolStripSplitButton + Friend WithEvents mnuToolBarHelp As ToolStripMenuItem + Friend WithEvents mnuDataWindowHelp As ToolStripMenuItem + Friend WithEvents mnuOutputHelp As ToolStripMenuItem + Friend WithEvents mnuLogScriptHelp As ToolStripMenuItem + Friend WithEvents mnuTbDataView As ToolStripSplitButton + Friend WithEvents mnuDataViewWindow As ToolStripMenuItem + Friend WithEvents mnuRDataViewerWindow As ToolStripMenuItem End Class diff --git a/instat/frmMain.vb b/instat/frmMain.vb index de20ca54564..d5c70d09531 100644 --- a/instat/frmMain.vb +++ b/instat/frmMain.vb @@ -303,7 +303,7 @@ Public Class frmMain mnuDataFrameMetadat.Checked = False mnuSwapDataLogScript.Checked = False mnuSwapDataMetadata.Checked = False - mnuTbDataView.Checked = True + mnuDataViewWindow.Checked = True mnuOutputWindow.Checked = True mnuLogScript.Checked = False UpdateLayout() @@ -364,7 +364,7 @@ Public Class frmMain MsgBox(ex.Message) End Try - mnuTbDataView.Checked = mnuViewDataView.Checked + mnuDataViewWindow.Checked = mnuViewDataView.Checked mnuOutputWindow.Checked = mnuViewOutput.Checked mnuLogScript.Checked = mnuViewLogScript.Checked End Sub @@ -852,13 +852,25 @@ Public Class frmMain End Sub Private Sub mnuHelpHelp_Click(sender As Object, e As EventArgs) - Help.ShowHelp(Me, strStaticPath & "\" & strHelpFilePath, HelpNavigator.TableOfContents, "") + Help.ShowHelp(Me, strStaticPath & "\" & strHelpFilePath, HelpNavigator.TopicId, "135") End Sub - Private Sub mnuTbHelp_Click(sender As Object, e As EventArgs) Handles mnuTbHelp.Click + Private Sub mnuTbHelp_Click(sender As Object, e As EventArgs) Handles mnuTbHelp.ButtonClick, mnuToolBarHelp.Click mnuHelpHelp_Click(sender, e) End Sub + Private Sub mnuDataWindowHelp_Click(sender As Object, e As EventArgs) Handles mnuDataWindowHelp.Click + Help.ShowHelp(Me, strStaticPath & "\" & strHelpFilePath, HelpNavigator.TopicId, "134") + End Sub + + Private Sub mnuOutputHelp_Click(sender As Object, e As EventArgs) Handles mnuOutputHelp.Click + Help.ShowHelp(Me, strStaticPath & "\" & strHelpFilePath, HelpNavigator.TopicId, "540") + End Sub + + Private Sub mnuLogScriptHelp_Click(sender As Object, e As EventArgs) Handles mnuLogScriptHelp.Click + Help.ShowHelp(Me, strStaticPath & "\" & strHelpFilePath, HelpNavigator.TopicId, "542") + End Sub + Private Sub mnuPrepareFactorRecode_Click(sender As Object, e As EventArgs) Handles mnuPrepareColumnFactorRecodeFactor.Click dlgRecodeFactor.ShowDialog() End Sub @@ -1150,7 +1162,7 @@ Public Class frmMain strCurrentStatus = tstatus.Text If clsRLink.bInstatObjectExists Then - tstatus.Text = "Auto saving data..." + tstatus.Text = GetTranslation("Auto saving data...") Cursor = Cursors.WaitCursor If Not Directory.Exists(strAutoSaveDataFolderPath) Then Directory.CreateDirectory(strAutoSaveDataFolderPath) @@ -1168,11 +1180,11 @@ Public Class frmMain clsSaveRDS.AddParameter("object", clsRLink.strInstatDataObject) clsSaveRDS.AddParameter("file", Chr(34) & strCurrentAutoSaveDataFilePath.Replace("\", "/") & Chr(34)) clsRLink.RunInternalScript(clsSaveRDS.ToScript(), bSilent:=True, bShowWaitDialogOverride:=False) + tstatus.Text = strCurrentStatus Cursor = Cursors.Default bFirstBackupDone = True End If - autoTranslate(Me) End Sub Public Sub DeleteAutoSaveFiles() @@ -1820,8 +1832,9 @@ Public Class frmMain dlgInfill.ShowDialog() End Sub - Private Sub mnuDataView_Click(sender As Object, e As EventArgs) Handles mnuTbDataView.Click + Private Sub mnuDataView_Click(sender As Object, e As EventArgs) Handles mnuTbDataView.ButtonClick, mnuDataViewWindow.Click mnuViewDataView.Checked = Not mnuViewDataView.Checked + mnuDataViewWindow.Checked = mnuViewDataView.Checked UpdateLayout() End Sub diff --git a/instat/sdgSummaries.vb b/instat/sdgSummaries.vb index 2398fc81117..f9dadb93332 100644 --- a/instat/sdgSummaries.vb +++ b/instat/sdgSummaries.vb @@ -45,13 +45,13 @@ Public Class sdgSummaries ucrPnlPosition.AddToLinkedControls({ucrChkFirst, ucrSelectorOrderBy, ucrReceiverOrderBy, ucrChkOrderBy, ucrChkLast, ucrChknth, ucrChkSample}, {rdoUsePositions}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) ucrPnlPosition.AddToLinkedControls({ucrChkWhichmin, ucrChkWhereMax, ucrChkWhereMin, ucrReceiverInclude, ucrSelectorInclude, ucrChkWhichmax}, {rdoDisplay}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True) - ucrChkNonMissing.SetParameter(New RParameter("summary_count_non_missing", 1), bNewChangeParameterValue:=True, bNewAddRemoveParameter:=True, strNewValueIfChecked:=Chr(34) & "summary_count_non_missing" & Chr(34), strNewValueIfUnchecked:=Chr(34) & Chr(34)) + ucrChkNonMissing.SetParameter(New RParameter("summary_count", 1), bNewChangeParameterValue:=True, bNewAddRemoveParameter:=True, strNewValueIfChecked:=Chr(34) & "summary_count" & Chr(34), strNewValueIfUnchecked:=Chr(34) & Chr(34)) ucrChkNonMissing.SetText("N Non Missing") - ucrChkNMissing.SetParameter(New RParameter("summary_count_missing", 2), bNewChangeParameterValue:=True, bNewAddRemoveParameter:=True, strNewValueIfChecked:=Chr(34) & "summary_count_missing" & Chr(34), strNewValueIfUnchecked:=Chr(34) & Chr(34)) + ucrChkNMissing.SetParameter(New RParameter("summary_count_miss", 2), bNewChangeParameterValue:=True, bNewAddRemoveParameter:=True, strNewValueIfChecked:=Chr(34) & "summary_count_miss" & Chr(34), strNewValueIfUnchecked:=Chr(34) & Chr(34)) ucrChkNMissing.SetText("N Missing") - ucrChkNTotal.SetParameter(New RParameter("summary_count", 3), bNewChangeParameterValue:=True, bNewAddRemoveParameter:=True, strNewValueIfChecked:=Chr(34) & "summary_count" & Chr(34), strNewValueIfUnchecked:=Chr(34) & Chr(34)) + ucrChkNTotal.SetParameter(New RParameter("summary_count_all", 3), bNewChangeParameterValue:=True, bNewAddRemoveParameter:=True, strNewValueIfChecked:=Chr(34) & "summary_count_all" & Chr(34), strNewValueIfUnchecked:=Chr(34) & Chr(34)) ucrChkNTotal.SetText("N Total") ucrChkMean.SetParameter(New RParameter("summary_mean", 4), bNewChangeParameterValue:=True, bNewAddRemoveParameter:=True, strNewValueIfChecked:=Chr(34) & "summary_mean" & Chr(34), strNewValueIfUnchecked:=Chr(34) & Chr(34)) diff --git a/instat/static/ClimateObject/R/BackendComponents/summary_functions.R b/instat/static/ClimateObject/R/BackendComponents/summary_functions.R index dda6d823766..892a6f0f6e1 100644 --- a/instat/static/ClimateObject/R/BackendComponents/summary_functions.R +++ b/instat/static/ClimateObject/R/BackendComponents/summary_functions.R @@ -1,7 +1,7 @@ # summary function labels sum_label="summary_sum" mode_label="summary_mode" -count_label="summary_count" +count_label="summary_count_all" count_over_threshold_label="summary_count_over_threshold" sd_label = "summary_sd" median_label = "summary_median" diff --git a/instat/static/InstatObject/R/Backend_Components/DisplayDaily.R b/instat/static/InstatObject/R/Backend_Components/DisplayDaily.R index 58a1eb73504..7d35d107093 100644 --- a/instat/static/InstatObject/R/Backend_Components/DisplayDaily.R +++ b/instat/static/InstatObject/R/Backend_Components/DisplayDaily.R @@ -221,9 +221,9 @@ DisplayDaily <- function(Datain,Stations,Variables,option=1,Years,Misscode,Trace outstats[st,(m+1)] <- gsub("\\s+","",outstats[st,(m+1)]) } } - # If all the data is NA, set the stats to NA (except summary_count_missing) + # If all the data is NA, set the stats to NA (except summary_count_miss) if(length(dat[,loc])==length(which(is.na(dat[,loc]==TRUE)))){ - outstats[which(monstats != "summary_count_missing"),(m+1)] <- "NA" + outstats[which(monstats != "summary_count_miss"),(m+1)] <- "NA" } # If there's no data, set all the stats to NA if(length(dat[,loc]) == 0) outstats[,(m+1)] <- "NA" @@ -278,7 +278,7 @@ DisplayDaily <- function(Datain,Stations,Variables,option=1,Years,Misscode,Trace out[dim(out)[1]+1,] <- "____" out[dim(out)[1],1] <- "STATS" # temp fix to shorten display name of summary function - outstats[,1][outstats[,1] == "summary_count_missing"] <- "n_miss" + outstats[,1][outstats[,1] == "summary_count_miss"] <- "n_miss" out <- rbind(out,outstats) #----------------------------------------------------------# diff --git a/instat/static/InstatObject/R/Backend_Components/calculations.R b/instat/static/InstatObject/R/Backend_Components/calculations.R index 6f1b349524e..ebb95254ec6 100644 --- a/instat/static/InstatObject/R/Backend_Components/calculations.R +++ b/instat/static/InstatObject/R/Backend_Components/calculations.R @@ -494,7 +494,10 @@ DataBook$set("public", "apply_instat_calculation", function(calc, curr_data_list # if it is a ordered factor... if (any(stringr::str_detect("ordered", col_data_type))){ # put in here the ones that DO work for ordered factor - if (any(grepl("summary_count_non_missing|summary_count_missing|summary_n_distinct|summary_count|summary_min|summary_max|summary_range|summary_median|summary_quantile|p10|p20|p25|p30|p33|p40|p60|p67|p70|p75|p80|p90", formula_fn_exp))){ + + + if (any(grepl("summary_count|summary_count_miss|summary_n_distinct|summary_count_all|summary_min|summary_max|summary_range|summary_median|summary_quantile|p10|p20|p25|p30|p33|p40|p60|p67|p70|p75|p80|p90", formula_fn_exp))){ + curr_data_list[[c_data_label]] <- curr_data_list[[c_data_label]] %>% dplyr::summarise(!!calc$result_name := !!rlang::parse_expr(calc$function_exp)) } else { @@ -505,7 +508,10 @@ DataBook$set("public", "apply_instat_calculation", function(calc, curr_data_list # if it is a factor or character, do not work for anything except... } else if (any(stringr::str_detect("factor | character", col_data_type))){ # put in here the ones that DO work for factor or character - if (any(grepl("summary_count_non_missing|summary_count_missing|summary_n_distinct|summary_count", formula_fn_exp))){ + + + if (any(grepl("summary_count|summary_count_miss|summary_n_distinct|summary_count_all", formula_fn_exp))){ + curr_data_list[[c_data_label]] <- curr_data_list[[c_data_label]] %>% dplyr::summarise(!!calc$result_name := !!rlang::parse_expr(calc$function_exp)) } else { diff --git a/instat/static/InstatObject/R/Backend_Components/summary_functions.R b/instat/static/InstatObject/R/Backend_Components/summary_functions.R index 4371ef75567..44779cf8d52 100644 --- a/instat/static/InstatObject/R/Backend_Components/summary_functions.R +++ b/instat/static/InstatObject/R/Backend_Components/summary_functions.R @@ -192,7 +192,10 @@ DataBook$set("public", "calculate_summary", function(data_name, columns_to_summa # function_exp <- paste0(function_exp, ", na.rm =", na.rm, ")") if(is.null(result_names)) { result_name = summaries_display[j] - if(include_columns_to_summarise) result_name = paste0(result_name, sep, column_names) + if(include_columns_to_summarise){ + if (!is.null(extra_args$y)) result_name <- paste0(result_name, sep, extra_args$y, sep, column_names) + else result_name <- paste0(result_name, sep, column_names) + } } #TODO result_names could be horizontal/vertical vector, matrix or single value else result_name <- result_names[i,j] @@ -281,7 +284,7 @@ DataBook$set("public", "summary", function(data_name, columns_to_summarise, summ calculated_from[[1]] <- list(data_name = data_name, columns = columns_to_summarise) summaries <- unique(summaries) summaries <- summaries[order(match(summaries, all_summaries))] - summaries_count <- summaries[startsWith(summaries, "summary_count")] + summaries_count <- summaries[startsWith(summaries, "summary_count_all")] summaries_other <- setdiff(summaries, summaries_count) summaries <- c(summaries_count, summaries_other) count_summaries_max <- length(summaries_count) @@ -444,9 +447,9 @@ missing_values_check <- function(x) { # summary function labels sum_label <- "summary_sum" mode_label <- "summary_mode" -count_label <- "summary_count" -count_missing_label <- "summary_count_missing" -count_non_missing_label <- "summary_count_non_missing" +count_label <- "summary_count_all" +count_missing_label <- "summary_count_miss" +count_non_missing_label <- "summary_count" sd_label <- "summary_sd" var_label <- "summary_var" median_label <- "summary_median" @@ -575,13 +578,13 @@ na_check <- function(x, na_type = c(), na_consecutive_n = NULL, na_max_n = NULL, for (i in seq_along(na_type)) { type <- na_type[i] if (type %in% c("n","'n'")) { - res[i] <- summary_count_missing(x) <= na_max_n + res[i] <- summary_count_miss(x) <= na_max_n } else if (type %in% c("prop","'prop'")) { - res[i] <- (summary_count_missing(x) / summary_count(x)) <= na_max_prop / 100 + res[i] <- (summary_count_miss(x) / summary_count(x)) <= na_max_prop / 100 } else if (type %in% c("n_non_miss","'n_non_miss'")) { - res[i] <- summary_count_non_missing(x) >= na_min_n + res[i] <- summary_count(x) >= na_min_n } else if (type %in% c("FUN","'FUN'")) { res[i] <- na_FUN(x, ...) @@ -719,16 +722,16 @@ summary_sum <- function (x, weights = NULL, na.rm = FALSE, na_type = "", ...) { } -summary_count <- function(x, ...) { +summary_count_all <- function(x, ...) { return(length(x)) } -summary_count_missing <- function(x, ...) { +summary_count_miss <- function(x, ...) { return(sum(is.na(x))) } -summary_count_non_missing <- function(x, ...) { +summary_count <- function(x, ...) { return(sum(!is.na(x))) } diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index 14171b6a9fd..2bea3ede08b 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 } @@ -4458,8 +4449,8 @@ DataSheet$set("public", "patch_climate_element", function(date_col_name = "", va } if (length(col) == dim(curr_data)[[1]]) { self$add_columns_to_data(col_name = column_name, col_data = col) - gaps_remaining <- summary_count_missing(col) - gaps_filled <- (summary_count_missing(curr_data[, var]) - gaps_remaining) + gaps_remaining <- summary_count_miss(col) + gaps_filled <- (summary_count_miss(curr_data[, var]) - gaps_remaining) cat(gaps_filled, " gaps filled", gaps_remaining, " remaining.", "\n") } else if (gaps != 0) { cat(gaps, " rows for date gaps are missing, fill date gaps before proceeding.", "\n") @@ -4654,39 +4645,79 @@ DataSheet$set("public", "has_labels", function(col_names) { } ) -DataSheet$set("public", "anova_tables2", function(x_col_names, y_col_name, total = FALSE, signif.stars = FALSE, sign_level = FALSE, means = FALSE) { - if (missing(x_col_names) || missing(y_col_name)) stop("Both x_col_names and y_col_names are required") +DataSheet$set("public", "anova_tables2", function(x_col_names, y_col_name, total = FALSE, signif.stars = FALSE, sign_level = FALSE, means = FALSE, interaction = FALSE) { + if (missing(x_col_names) || missing(y_col_name)) stop("Both x_col_names and y_col_name are required") if (sign_level || signif.stars) message("This is no longer descriptive") - if (sign_level) end_col = 5 else end_col = 4 + end_col <- if (sign_level) 5 else 4 + # Construct the formula if (length(x_col_names) == 1) { - formula_str <- paste0(as.name(y_col_name), "~ ", as.name(x_col_names)) - } else if (length(x_col_names) > 1) { - formula_str <- paste0(as.name(y_col_name), "~ ", as.name(paste(x_col_names, collapse = " + "))) + formula_str <- paste0(as.name(y_col_name), " ~ ", as.name(x_col_names)) + } else if (interaction && length(x_col_names) > 1) { + formula_str <- paste0(as.name(y_col_name), " ~ ", as.name(paste(x_col_names, collapse = " * "))) + } else { + formula_str <- paste0(as.name(y_col_name), " ~ ", as.name(paste(x_col_names, collapse = " + "))) } - - # Fit the model + mod <- lm(formula = as.formula(formula_str), data = self$get_data_frame()) - anova_mod <- anova(mod)[1:end_col] %>% tibble::as_tibble(rownames = " ") + anova_mod <- anova(mod)[1:end_col] + + # Process ANOVA table + anova_mod <- anova_mod %>% + dplyr::mutate( + `Sum Sq` = signif(`Sum Sq`, 3), + `Mean Sq` = signif(`Mean Sq`, 3), + `F value` = ifelse(`F value` < 100, round(`F value`, 1), round(`F value`)) + ) %>% + dplyr::mutate(`F value` = as.character(`F value`)) %>% + dplyr::mutate(across(`F value`, ~ tidyr::replace_na(., "--"))) %>% + tibble::as_tibble(rownames = " ") # Add the total row if requested - if (total) anova_mod <- anova_mod %>% tibble::add_row(` ` = "Total", dplyr::summarise(., across(where(is.numeric), sum))) - anova_mod$`F value` <- round(anova_mod$`F value`, 4) - if (sign_level) anova_mod$`Pr(>F)` <- format.pval(anova_mod$`Pr(>F)`, digits = 4, eps = 0.001) - cat(paste0("ANOVA of ", formula_str, ":\n")) - print(anova_mod) + if (total) { + anova_mod <- anova_mod %>% + tibble::add_row(` ` = "Total", dplyr::summarise(., across(where(is.numeric), sum))) %>% + dplyr::mutate(`F value` = ifelse(` ` == "Total", "--", `F value`)) # Replace NA with "--" for Total row + } + + # Handle significance levels + if (sign_level) { + anova_mod <- anova_mod %>% + dplyr::mutate( + `Pr(>F)` = ifelse( + is.na(`Pr(>F)`) | !is.numeric(`Pr(>F)`), "--", + ifelse(`Pr(>F)` < 0.001, "<0.001", formatC(`Pr(>F)`, format = "f", digits = 3)) + ) + ) + } + + # Generate the table with a title + title <- paste0("ANOVA of ", formula_str) + formatted_table <- anova_mod %>% + knitr::kable(format = "simple", caption = title) + + print(formatted_table) + + # Add line break before means section cat("\n") - # Optionally print means + + # Optionally print means or model coefficients if (means) { - if (class(mod$model[[x_col_names]]) %in% c("numeric", "integer")){ - cat("Model coefficients:\n") - print(mod$coefficients) - cat("\n") + has_numeric <- any(sapply(x_col_names, function(x) class(mod$model[[x]]) %in% c("numeric", "integer"))) + has_factor <- any(sapply(x_col_names, function(x) class(mod$model[[x]]) == "factor")) + + if (has_numeric && has_factor) { + cat("Model coefficients:\n") + print(mod$coefficients) + } else if (class(mod$model[[x_col_names[[1]]]]) %in% c("numeric", "integer")) { + cat("Model coefficients:\n") + print(mod$coefficients) } else { - cat(paste0("Means table of ", y_col_name, ":\n")) - print(model.tables(aov(mod), type = "means")) - cat("\n") + cat(paste0("Means tables of ", y_col_name, ":\n")) + means_table <- capture.output(model.tables(aov(mod), type = "means")) + means_table <- means_table[-1] + cat(paste(means_table, collapse = "\n")) } } } diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index 5270526bc58..b8ccb4a5c6c 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -3043,7 +3043,7 @@ DataBook$set("public","wrap_or_unwrap_data", function(data_name, col_name, colum } ) -DataBook$set("public", "anova_tables2", function(data_name, x_col_names, y_col_name, total = TRUE, signif.stars = FALSE, sign_level = FALSE, means = FALSE) { - self$get_data_objects(data_name)$anova_tables2(x_col_names = x_col_names, y_col_name = y_col_name, total = total, signif.stars = signif.stars, sign_level = sign_level, means = means) +DataBook$set("public", "anova_tables2", function(data_name, x_col_names, y_col_name, total = TRUE, signif.stars = FALSE, sign_level = FALSE, means = FALSE, interaction=FALSE) { + self$get_data_objects(data_name)$anova_tables2(x_col_names = x_col_names, y_col_name = y_col_name, total = total, signif.stars = signif.stars, sign_level = sign_level, means = means, interaction=interaction) } ) diff --git a/instat/translations/rInstatTranslations.db b/instat/translations/rInstatTranslations.db index b93a21cd916..03eb772e1dc 100644 Binary files a/instat/translations/rInstatTranslations.db and b/instat/translations/rInstatTranslations.db differ