Skip to content

Commit

Permalink
Merge pull request #980 from nyagishira/dlgOneWayANOVA
Browse files Browse the repository at this point in the history
dlgOneWayANOVA
  • Loading branch information
dannyparsons committed Mar 1, 2016
2 parents d135723 + 3c5b670 commit a4abd06
Show file tree
Hide file tree
Showing 4 changed files with 286 additions and 41 deletions.
87 changes: 54 additions & 33 deletions instat/dlgOneWayAnova.vb
Original file line number Diff line number Diff line change
@@ -1,62 +1,83 @@
' 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 <http://www.gnu.org/licenses/>.
' 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 <http://www.gnu.org/licenses/>.
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:=ucrFactor.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()
sdgANOVAOptions.ShowDialog()
End Sub
Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset
SetDefaultSettings()
End Sub
End Class
17 changes: 9 additions & 8 deletions instat/instat.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,10 @@
<Compile Include="sdgHistogramOptions.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="sdgOptions.Designer.vb">
<DependentUpon>sdgOptions.vb</DependentUpon>
<Compile Include="sdgANOVAOptions.Designer.vb">
<DependentUpon>sdgANOVAOptions.vb</DependentUpon>
</Compile>
<Compile Include="sdgOptions.vb">
<Compile Include="sdgANOVAOptions.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="sdgRestrict.Designer.vb">
Expand Down Expand Up @@ -1602,13 +1602,14 @@
<DependentUpon>sdgHistogramOptions.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="sdgOptions.fr-FR.resx">
<DependentUpon>sdgOptions.vb</DependentUpon>
<DependentUpon>sdgANOVAOptions.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="sdgOptions.resx">
<DependentUpon>sdgOptions.vb</DependentUpon>
<EmbeddedResource Include="sdgANOVAOptions.resx">
<DependentUpon>sdgANOVAOptions.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="sdgOptions.sw-KE.resx">
<DependentUpon>sdgOptions.vb</DependentUpon>
<EmbeddedResource Include="sdgANOVAOptions.sw-KE.resx">
<DependentUpon>sdgANOVAOptions.vb</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="sdgPrincipalComponentAnalysis.fr-FR.resx">
<DependentUpon>sdgPrincipalComponentAnalysis.vb</DependentUpon>
Expand Down
168 changes: 168 additions & 0 deletions instat/sdgANOVAOptions.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions instat/sdgANOVAOptions.vb
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
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

0 comments on commit a4abd06

Please sign in to comment.