From d5862e95044d36d6b6e4cbaa4f6d3f2b91b432a2 Mon Sep 17 00:00:00 2001 From: Mary Mutahi Date: Tue, 1 Mar 2016 10:09:40 +0300 Subject: [PATCH 1/3] changes on the code --- instat/dlgOneWayAnova.vb | 86 +++++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 33 deletions(-) diff --git a/instat/dlgOneWayAnova.vb b/instat/dlgOneWayAnova.vb index 14823c8ffa0..8a6070398dc 100644 --- a/instat/dlgOneWayAnova.vb +++ b/instat/dlgOneWayAnova.vb @@ -1,62 +1,82 @@ -' Instat-R -' Copyright (C) 2015 -' -' This program is free software: you can redistribute it and/or modify -' it under the terms of the GNU General Public License as published by -' the Free Software Foundation, either version 3 of the License, or -' (at your option) any later version. -' -' This program is distributed in the hope that it will be useful, -' but WITHOUT ANY WARRANTY; without even the implied warranty of -' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -' GNU General Public License for more details. -' -' You should have received a copy of the GNU General Public License k -' along with this program. If not, see . +' Instat-R +' Copyright (C) 2015 +' +' This program is free software: you can redistribute it and/or modify +' it under the terms of the GNU General Public License as published by +' the Free Software Foundation, either version 3 of the License, or +' (at your option) any later version. +' +' This program is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU General Public License for more details. +' +' You should have received a copy of the GNU General Public License k +' along with this program. If not, see . Imports instat.Translations + Public Class dlgOneWayANOVA - Private Sub dlgOneWayAnova_Load(sender As Object, e As EventArgs) Handles MyBase.Load + + Public bFirstLoad As Boolean = True + Dim clsModel As New ROperator + + Private Sub dlgOneWayAnova_Load(sender As Object, e As EventArgs) Handles MyBase.Load + If bFirstLoad Then + InitialiseDialog() + SetDefaultSettings() + bFirstLoad = False + End If + + End Sub + + Private Sub InitialiseDialog() ucrBase.clsRsyntax.SetFunction("aov") ucrBase.clsRsyntax.iCallType = 2 ucrYVariate.Selector = ucrAddRemoveDataFrame - ucrYVariate.SetMeAsReceiver() ucrFactor.Selector = ucrAddRemoveDataFrame - ucrFactor.SetDataType("factor") - ucrBase.clsRsyntax.AddParameter("data", clsRFunctionParameter:=ucrAddRemoveDataFrame.ucrAvailableDataFrames.clsCurrDataFrame) + clsModel.SetOperation("~") + autoTranslate(Me) - Fillformula() + ucrBase.iHelpTopicID = 315 End Sub + Private Sub SetDefaultSettings() + ucrAddRemoveDataFrame.Reset() + ucrAddRemoveDataFrame.Focus() + ucrYVariate.SetMeAsReceiver() + TestOKEnabled() - Private Sub ucrYVariate_ValueChanged(sender As Object, e As EventArgs) Handles ucrYVariate.ValueChanged - Fillformula() End Sub - Private Sub ucrFactor_ValueChanged(sender As Object, e As EventArgs) Handles ucrFactor.ValueChanged - Fillformula() - End Sub - Private Sub Fillformula() - Dim strFactor As String = "" - Dim strYVariate As String = "" - strYVariate = ucrYVariate.GetVariableNames(bWithQuotes:=False) - strFactor = ucrFactor.GetVariableNames(bWithQuotes:=False) - If ((Not (strYVariate = "")) And (Not (strFactor = ""))) Then - ucrBase.clsRsyntax.AddParameter("formula", strYVariate & "~" & strFactor) + Private Sub ucrYVariate_SelectionChanged(sender As Object, e As EventArgs) Handles ucrYVariate.SelectionChanged + clsModel.SetParameter(True, strValue:=ucrYVariate.GetVariableNames(bWithQuotes:=False)) + TestOKEnabled() + End Sub + Private Sub ucrFactor_SelectionChanged(sender As Object, e As EventArgs) Handles ucrFactor.SelectionChanged + clsModel.SetParameter(False, strValue:=ucrYVariate.GetVariableNames(bWithQuotes:=False)) + TestOKEnabled() + End Sub + Private Sub TestOKEnabled() + If (Not ucrYVariate.IsEmpty()) And (Not ucrFactor.IsEmpty()) Then + ucrBase.clsRsyntax.AddParameter("formula", clsROperatorParameter:=clsModel) ucrBase.OKEnabled(True) Else ucrBase.OKEnabled(False) End If End Sub - Private Sub ucrAddRemoveDataframe_Leave(sender As Object, e As EventArgs) Handles ucrAddRemoveDataFrame.Leave + Private Sub ucrAddRemoveDataframe_DataFrameChanged() Handles ucrAddRemoveDataFrame.DataFrameChanged ucrBase.clsRsyntax.AddParameter("data", clsRFunctionParameter:=ucrAddRemoveDataFrame.ucrAvailableDataFrames.clsCurrDataFrame) End Sub Private Sub cmdOptions_Click(sender As Object, e As EventArgs) Handles cmdOptions.Click sdgOptions.ShowDialog() End Sub + Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset + SetDefaultSettings() + End Sub End Class \ No newline at end of file From 9d198e0eb912ec2857d4e363342b28e2b33c6f36 Mon Sep 17 00:00:00 2001 From: Mary Mutahi Date: Tue, 1 Mar 2016 12:58:39 +0300 Subject: [PATCH 2/3] creating the ANOVA dialog and the subdialog --- instat/dlgOneWayAnova.vb | 4 +- instat/instat.vbproj | 17 +-- instat/sdgANOVAOptions.Designer.vb | 168 +++++++++++++++++++++++++++++ instat/sdgANOVAOptions.vb | 55 ++++++++++ 4 files changed, 234 insertions(+), 10 deletions(-) create mode 100644 instat/sdgANOVAOptions.Designer.vb create mode 100644 instat/sdgANOVAOptions.vb diff --git a/instat/dlgOneWayAnova.vb b/instat/dlgOneWayAnova.vb index 8a6070398dc..057921b4826 100644 --- a/instat/dlgOneWayAnova.vb +++ b/instat/dlgOneWayAnova.vb @@ -56,7 +56,7 @@ Public Class dlgOneWayANOVA End Sub Private Sub ucrFactor_SelectionChanged(sender As Object, e As EventArgs) Handles ucrFactor.SelectionChanged - clsModel.SetParameter(False, strValue:=ucrYVariate.GetVariableNames(bWithQuotes:=False)) + clsModel.SetParameter(False, strValue:=ucrFactor.GetVariableNames(bWithQuotes:=False)) TestOKEnabled() End Sub @@ -74,7 +74,7 @@ Public Class dlgOneWayANOVA End Sub Private Sub cmdOptions_Click(sender As Object, e As EventArgs) Handles cmdOptions.Click - sdgOptions.ShowDialog() + sdgANOVAOptions.ShowDialog() End Sub Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset SetDefaultSettings() diff --git a/instat/instat.vbproj b/instat/instat.vbproj index 7ab22823059..63400e16533 100644 --- a/instat/instat.vbproj +++ b/instat/instat.vbproj @@ -334,10 +334,10 @@ Form - - sdgOptions.vb + + sdgANOVAOptions.vb - + Form @@ -1536,13 +1536,14 @@ sdgHistogramOptions.vb - sdgOptions.vb + sdgANOVAOptions.vb - - sdgOptions.vb + + sdgANOVAOptions.vb - - sdgOptions.vb + + sdgANOVAOptions.vb + Designer sdgRestrict.vb diff --git a/instat/sdgANOVAOptions.Designer.vb b/instat/sdgANOVAOptions.Designer.vb new file mode 100644 index 00000000000..e81f5b8cbc4 --- /dev/null +++ b/instat/sdgANOVAOptions.Designer.vb @@ -0,0 +1,168 @@ + _ +Partial Class sdgANOVAOptions + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.tbcOptions = New System.Windows.Forms.TabControl() + Me.tbpDisplay = New System.Windows.Forms.TabPage() + Me.chkTableOfMeans = New System.Windows.Forms.CheckBox() + Me.chkEstimateValues = New System.Windows.Forms.CheckBox() + Me.chkANOVATable = New System.Windows.Forms.CheckBox() + Me.tbpGraphics = New System.Windows.Forms.TabPage() + Me.chkMeans = New System.Windows.Forms.CheckBox() + Me.chkResiduals = New System.Windows.Forms.CheckBox() + Me.ucrBaseSdg = New instat.ucrButtonsSubdialogue() + Me.tbcOptions.SuspendLayout() + Me.tbpDisplay.SuspendLayout() + Me.tbpGraphics.SuspendLayout() + Me.SuspendLayout() + ' + 'tbcOptions + ' + Me.tbcOptions.Controls.Add(Me.tbpDisplay) + Me.tbcOptions.Controls.Add(Me.tbpGraphics) + Me.tbcOptions.Location = New System.Drawing.Point(-1, -1) + Me.tbcOptions.Name = "tbcOptions" + Me.tbcOptions.SelectedIndex = 0 + Me.tbcOptions.Size = New System.Drawing.Size(292, 165) + Me.tbcOptions.TabIndex = 1 + ' + 'tbpDisplay + ' + Me.tbpDisplay.Controls.Add(Me.chkTableOfMeans) + Me.tbpDisplay.Controls.Add(Me.chkEstimateValues) + Me.tbpDisplay.Controls.Add(Me.chkANOVATable) + Me.tbpDisplay.Location = New System.Drawing.Point(4, 22) + Me.tbpDisplay.Name = "tbpDisplay" + Me.tbpDisplay.Padding = New System.Windows.Forms.Padding(3) + Me.tbpDisplay.Size = New System.Drawing.Size(284, 139) + Me.tbpDisplay.TabIndex = 0 + Me.tbpDisplay.Tag = "Display" + Me.tbpDisplay.Text = "Display" + Me.tbpDisplay.UseVisualStyleBackColor = True + ' + 'chkTableOfMeans + ' + Me.chkTableOfMeans.AutoSize = True + Me.chkTableOfMeans.Location = New System.Drawing.Point(9, 105) + Me.chkTableOfMeans.Name = "chkTableOfMeans" + Me.chkTableOfMeans.Size = New System.Drawing.Size(99, 17) + Me.chkTableOfMeans.TabIndex = 5 + Me.chkTableOfMeans.Tag = "Table_of_means" + Me.chkTableOfMeans.Text = "Table of means" + Me.chkTableOfMeans.UseVisualStyleBackColor = True + ' + 'chkEstimateValues + ' + Me.chkEstimateValues.AutoSize = True + Me.chkEstimateValues.Location = New System.Drawing.Point(10, 62) + Me.chkEstimateValues.Name = "chkEstimateValues" + Me.chkEstimateValues.Size = New System.Drawing.Size(67, 17) + Me.chkEstimateValues.TabIndex = 4 + Me.chkEstimateValues.Tag = "P_values" + Me.chkEstimateValues.Text = "P values" + Me.chkEstimateValues.UseVisualStyleBackColor = True + ' + 'chkANOVATable + ' + Me.chkANOVATable.AutoSize = True + Me.chkANOVATable.Location = New System.Drawing.Point(10, 20) + Me.chkANOVATable.Name = "chkANOVATable" + Me.chkANOVATable.Size = New System.Drawing.Size(93, 17) + Me.chkANOVATable.TabIndex = 1 + Me.chkANOVATable.Tag = "ANOVA Table" + Me.chkANOVATable.Text = "ANOVA Table" + Me.chkANOVATable.UseVisualStyleBackColor = True + ' + 'tbpGraphics + ' + Me.tbpGraphics.Controls.Add(Me.chkMeans) + Me.tbpGraphics.Controls.Add(Me.chkResiduals) + Me.tbpGraphics.Location = New System.Drawing.Point(4, 22) + Me.tbpGraphics.Name = "tbpGraphics" + Me.tbpGraphics.Padding = New System.Windows.Forms.Padding(3) + Me.tbpGraphics.Size = New System.Drawing.Size(175, 155) + Me.tbpGraphics.TabIndex = 1 + Me.tbpGraphics.Tag = "Graphics" + Me.tbpGraphics.Text = "Graphics" + Me.tbpGraphics.UseVisualStyleBackColor = True + ' + 'chkMeans + ' + Me.chkMeans.AutoSize = True + Me.chkMeans.Location = New System.Drawing.Point(18, 71) + Me.chkMeans.Name = "chkMeans" + Me.chkMeans.Size = New System.Drawing.Size(58, 17) + Me.chkMeans.TabIndex = 1 + Me.chkMeans.Tag = "Means" + Me.chkMeans.Text = "Means" + Me.chkMeans.UseVisualStyleBackColor = True + ' + 'chkResiduals + ' + Me.chkResiduals.AutoSize = True + Me.chkResiduals.Location = New System.Drawing.Point(18, 24) + Me.chkResiduals.Name = "chkResiduals" + Me.chkResiduals.Size = New System.Drawing.Size(72, 17) + Me.chkResiduals.TabIndex = 0 + Me.chkResiduals.Tag = "Residuals" + Me.chkResiduals.Text = "Residuals" + Me.chkResiduals.UseVisualStyleBackColor = True + ' + 'ucrBaseSdg + ' + Me.ucrBaseSdg.Location = New System.Drawing.Point(48, 170) + Me.ucrBaseSdg.Name = "ucrBaseSdg" + Me.ucrBaseSdg.Size = New System.Drawing.Size(142, 30) + Me.ucrBaseSdg.TabIndex = 2 + ' + 'sdgANOVAOptions + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(290, 208) + Me.Controls.Add(Me.ucrBaseSdg) + Me.Controls.Add(Me.tbcOptions) + Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow + Me.Name = "sdgANOVAOptions" + Me.Tag = "ANOVA_options" + Me.Text = "ANOVA options" + Me.tbcOptions.ResumeLayout(False) + Me.tbpDisplay.ResumeLayout(False) + Me.tbpDisplay.PerformLayout() + Me.tbpGraphics.ResumeLayout(False) + Me.tbpGraphics.PerformLayout() + Me.ResumeLayout(False) + + End Sub + + Friend WithEvents ucrBaseSubdialog As ucrButtonsSubdialogue + Friend WithEvents tbcOptions As TabControl + Friend WithEvents tbpDisplay As TabPage + Friend WithEvents chkTableOfMeans As CheckBox + Friend WithEvents chkEstimateValues As CheckBox + Friend WithEvents chkANOVATable As CheckBox + Friend WithEvents tbpGraphics As TabPage + Friend WithEvents chkMeans As CheckBox + Friend WithEvents chkResiduals As CheckBox + Friend WithEvents ucrBaseSdg As ucrButtonsSubdialogue +End Class diff --git a/instat/sdgANOVAOptions.vb b/instat/sdgANOVAOptions.vb new file mode 100644 index 00000000000..6c0719d04c2 --- /dev/null +++ b/instat/sdgANOVAOptions.vb @@ -0,0 +1,55 @@ +' Instat-R +' Copyright (C) 2015 +' +' This program is free software: you can redistribute it and/or modify +' it under the terms of the GNU General Public License as published by +' the Free Software Foundation, either version 3 of the License, or +' (at your option) any later version. +' +' This program is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU General Public License for more details. +' +' You should have received a copy of the GNU General Public License k +' along with this program. If not, see . +Imports instat.Translations + +Public Class sdgANOVAOptions + + Public clsRModelFunction As RFunction + Public clsRaovFunction As New RFunction + Public bFirstLoad As Boolean = True + + + Private Sub sdgANOVAOptions_Load(sender As Object, e As EventArgs) Handles MyBase.Load + + autoTranslate(Me) + + If bFirstLoad Then + SetDefaultSettings() + bFirstLoad = False + End If + End Sub + + Public Sub SetRModelFunction(clsRModelFunc As RFunction) + clsRModelFunction = clsRModelFunc + End Sub + + Public Sub SetDefaultSettings() + chkANOVATable.Checked = True + End Sub + + Private Sub AnovaTable() + clsRaovFunction.SetRCommand("aov") + clsRaovFunction.AddParameter("", clsRFunctionParameter:=clsRModelFunction) + frmMain.clsRLink.RunScript(clsRaovFunction.ToScript(), 2) + End Sub + + Public Sub Estimates() + If (chkANOVATable.Checked) Then + AnovaTable() + End If + End Sub + +End Class \ No newline at end of file From 3c5b6704f18c3b90cf6c467a90281d4b6837e1fc Mon Sep 17 00:00:00 2001 From: Mary Mutahi Date: Tue, 1 Mar 2016 13:05:08 +0300 Subject: [PATCH 3/3] more correctios on the dialog --- instat/dlgOneWayAnova.vb | 1 + 1 file changed, 1 insertion(+) diff --git a/instat/dlgOneWayAnova.vb b/instat/dlgOneWayAnova.vb index 057921b4826..1c68942e2fe 100644 --- a/instat/dlgOneWayAnova.vb +++ b/instat/dlgOneWayAnova.vb @@ -34,6 +34,7 @@ Public Class dlgOneWayANOVA ucrBase.clsRsyntax.iCallType = 2 ucrYVariate.Selector = ucrAddRemoveDataFrame ucrFactor.Selector = ucrAddRemoveDataFrame + ucrFactor.SetDataType("factor") clsModel.SetOperation("~") autoTranslate(Me)