Skip to content

Commit

Permalink
Merge pull request #45 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
fetching latest copy of master
  • Loading branch information
maxwellfundi committed Mar 1, 2016
2 parents dc3b74b + a4abd06 commit ba65fee
Show file tree
Hide file tree
Showing 6 changed files with 378 additions and 62 deletions.
25 changes: 14 additions & 11 deletions instat/dlgCorrelation.designer.vb

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

88 changes: 78 additions & 10 deletions instat/dlgCorrelation.vb
Original file line number Diff line number Diff line change
Expand Up @@ -14,46 +14,82 @@
' 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 dlgCorrelation
Public bFirstLoad As Boolean = True
Public bIsTwoColumnFunction As Boolean

Private Sub dlgCorrelation_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'Set properties needed on load
ucrBase.clsRsyntax.iCallType = 2
ucrReceiverFirstColumn.Selector = ucrSelectorDataFrameVarAddRemove
ucrReceiverSecondColumn.Selector = ucrSelectorDataFrameVarAddRemove
ucrReceiverMultipleColumns.Selector = ucrSelectorDataFrameVarAddRemove
ucrReceiverFirstColumn.SetDataType("numeric")
ucrReceiverSecondColumn.SetDataType("numeric")
ucrReceiverMultipleColumns.SetDataType("numeric")

autoTranslate(Me)

'this default is independent of TwoColumn/MultipleColumn option so can be set here
rdoPearson.Checked = True
ucrBase.clsRsyntax.AddParameter("method", Chr(34) & "pearson" & Chr(34))
ucrBase.iHelpTopicID = 316

If bFirstLoad Then
SetDefaults()
bFirstLoad = False
End If

If bIsTwoColumnFunction Then
TestOKEnabledForTwoColumns()
Else
TestOKEnabledForMultipleColumns()
End If

'default is the TwoColumn option
End Sub

Private Sub SetDefaults()
ucrSelectorDataFrameVarAddRemove.Reset()
ucrSelectorDataFrameVarAddRemove.Focus()
rdoPearson.Checked = True
rdoTwoColumns.Checked = True
SetTwoColumnAsFunction()
TestOKEnabledForTwoColumns()
End Sub

Private Sub ucrReceiverFirstColumn_Leave(sender As Object, e As EventArgs) Handles ucrReceiverFirstColumn.Leave


Private Sub ucrReceiverFirstColumn_SelectionChanged(sender As Object, e As EventArgs) Handles ucrReceiverFirstColumn.SelectionChanged
ucrBase.clsRsyntax.AddParameter("x", clsRFunctionParameter:=ucrReceiverFirstColumn.GetVariables())
TestOKEnabledForTwoColumns()
End Sub

Private Sub ucrReceiverSecondColumn_Leave(sender As Object, e As EventArgs) Handles ucrReceiverSecondColumn.Leave
Private Sub ucrReceiverSecondColumn_SelectionChanged(sender As Object, e As EventArgs) Handles ucrReceiverSecondColumn.SelectionChanged
ucrBase.clsRsyntax.AddParameter("y", clsRFunctionParameter:=ucrReceiverSecondColumn.GetVariables())
TestOKEnabledforTwoColumns()

End Sub

Private Sub ucrReceiverMultipleColumns_Leave(sender As Object, e As EventArgs) Handles ucrReceiverMultipleColumns.Leave
Private Sub ucrReceiverMultipleColumns_SelectionChanged() Handles ucrReceiverMultipleColumns.SelectionChanged
ucrBase.clsRsyntax.AddParameter("x", clsRFunctionParameter:=ucrReceiverMultipleColumns.GetVariables())
TestOKEnabledForMultipleColumns()
End Sub

'put all rdo button checked changed in one sub to make it shorter
Private Sub rdoForMethodsCheckedChanged(sender As Object, e As EventArgs) Handles rdoPearson.CheckedChanged, rdoKendall.CheckedChanged, rdoSpearman.CheckedChanged
If rdoPearson.Checked Then
ucrBase.clsRsyntax.AddParameter("method", Chr(34) & "pearson" & Chr(34))
If frmMain.clsInstatOptions.bIncludeRDefaultParameters Then
ucrBase.clsRsyntax.AddParameter("method", Chr(34) & "pearson" & Chr(34))
Else
ucrBase.clsRsyntax.RemoveParameter("method")
End If
ElseIf rdoKendall.Checked Then
ucrBase.clsRsyntax.AddParameter("method", Chr(34) & "kendall" & Chr(34))

ElseIf rdoSpearman.Checked Then
ucrBase.clsRsyntax.AddParameter("method", Chr(34) & "spearman" & Chr(34))

Else
ucrBase.clsRsyntax.RemoveParameter("method")

'the else case should never happen but is there just in case
End If
End Sub
Expand All @@ -65,10 +101,15 @@ Public Class dlgCorrelation
Private Sub SetUseParameter()
If rdoCompleteRowsOnly.Checked Then
ucrBase.clsRsyntax.AddParameter("use", Chr(34) & "pairwise.complete.obs" & Chr(34))


ElseIf rdoPairwise.Checked Then
ucrBase.clsRsyntax.AddParameter("use", Chr(34) & "complete.obs" & Chr(34))


Else
ucrBase.clsRsyntax.RemoveParameter("use")

End If
End Sub

Expand All @@ -79,7 +120,7 @@ Public Class dlgCorrelation
ucrBase.clsRsyntax.SetFunction("cor.test")
'Set what should be visible/invisible
grpMissing.Visible = False
cmdPlots.Visible = False
cmdCorrplot.Visible = False
lblConfInterval.Visible = True
txtConfidenceInterval.Visible = True
ucrReceiverFirstColumn.Visible = True
Expand All @@ -96,6 +137,9 @@ Public Class dlgCorrelation
ucrBase.clsRsyntax.AddParameter("y", clsRFunctionParameter:=ucrReceiverSecondColumn.GetVariables())
ucrBase.clsRsyntax.AddParameter("alternative", Chr(34) & "two.sided" & Chr(34))
ucrBase.clsRsyntax.AddParameter("exact", "NULL")
bIsTwoColumnFunction = True


End Sub

Private Sub SetMultipleColumnAsFunction()
Expand All @@ -104,7 +148,7 @@ Public Class dlgCorrelation
ucrBase.clsRsyntax.SetFunction("cor")
'Set what should be visible/invisible
grpMissing.Visible = True
cmdPlots.Visible = True
cmdCorrplot.Visible = True
lblConfInterval.Visible = False
txtConfidenceInterval.Visible = False
ucrReceiverFirstColumn.Visible = False
Expand All @@ -118,6 +162,7 @@ Public Class dlgCorrelation
'Add back in parameters they may have been removed in TwoColumn case
SetUseParameter()
ucrBase.clsRsyntax.AddParameter("x", clsRFunctionParameter:=ucrReceiverMultipleColumns.GetVariables())
bIsTwoColumnFunction = False
End Sub


Expand All @@ -132,4 +177,27 @@ Public Class dlgCorrelation
Private Sub txtConfidenceInterval_Leave(sender As Object, e As EventArgs) Handles txtConfidenceInterval.Leave
ucrBase.clsRsyntax.AddParameter("conf.level", txtConfidenceInterval.Text)
End Sub
Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset
SetDefaults()
End Sub

Private Sub cmdPlots_Click(sender As Object, e As EventArgs) Handles cmdCorrplot.Click
sdgCorrPlot.ShowDialog()
End Sub
Private Sub TestOKEnabledForTwoColumns()
If ucrReceiverFirstColumn.IsEmpty() = False And ucrReceiverSecondColumn.IsEmpty() = False And (rdoPearson.Checked = True Or rdoKendall.Checked = True Or rdoSpearman.Checked = True) Then
ucrBase.OKEnabled(True)
Else
ucrBase.OKEnabled(False)
End If
End Sub
Private Sub TestOKEnabledForMultipleColumns()
If ucrReceiverMultipleColumns.IsEmpty() = False And ucrReceiverMultipleColumns.lstSelectedVariables.Items.Count > 1 And (rdoCompleteRowsOnly.Checked = True Or rdoPairwise.Checked = True) AndAlso (rdoPearson.Checked = True Or rdoKendall.Checked = True Or rdoSpearman.Checked = True) Then
ucrBase.OKEnabled(True)
Else
ucrBase.OKEnabled(False)
End If


End Sub
End Class
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
Loading

0 comments on commit ba65fee

Please sign in to comment.