Skip to content

Commit

Permalink
Merge pull request #105 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
merge from main
  • Loading branch information
dannyparsons committed Mar 16, 2016
2 parents 28da384 + f1be1ea commit fcd5ba1
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 65 deletions.
131 changes: 93 additions & 38 deletions instat/dlgRowStats.Designer.vb

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

72 changes: 45 additions & 27 deletions instat/dlgRowStats.vb
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,11 @@
' along with this program. If not, see <http://www.gnu.org/licenses/>.
Imports instat.Translations
Public Class dlgRowStats
Public bFirstLoad As Boolean = False
Private Sub dlgRowStats_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Public bFirstLoad As Boolean = True
Private Sub dlgRowStats_Load(sender As Object, e As EventArgs) Handles MyBase.Load
autoTranslate(Me)
ucrBase.clsRsyntax.SetFunction("apply")
ucrReceiverForRowStatistics.Selector = ucrSelectorForRowStats
ucrReceiverForRowStatistics.SetMeAsReceiver()
ucrBase.clsRsyntax.AddParameter("MARGIN", 1)
ucrNewColumnSelectorForRowStats.SetDataFrameSelector(ucrSelectorForRowStats.ucrAvailableDataFrames)
ucrNewColumnSelectorForRowStats.SetPrefix("Row_Summary")
ucrBase.clsRsyntax.SetAssignTo(strAssignToName:=ucrNewColumnSelectorForRowStats.cboColumnName.Text, strTempDataframe:=ucrSelectorForRowStats.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempColumn:=ucrNewColumnSelectorForRowStats.cboColumnName.Text)

If bFirstLoad Then
InitialiseDialog()
SetDefaults()
bFirstLoad = False
Else
Expand All @@ -40,20 +33,39 @@ Public Class dlgRowStats

Private Sub SetDefaults()
ucrSelectorForRowStats.Reset()
ucrSelectorForRowStats.Focus()
ucrInputcboRowSummary.SetPrefix("RowSummary")
End Sub

Private Sub ReopenDialog()

ucrInputcboRowSummary.SetPrefix("RowSummary")
End Sub

Private Sub TestOKEnabled()
If ucrReceiverForRowStatistics.IsEmpty() = False Then
If Not ucrReceiverForRowStatistics.IsEmpty Then
ucrBase.OKEnabled(True)
Else
ucrBase.OKEnabled(False)
End If
End Sub

'this is only temporary and needs to be worked on later
Private Sub InitialiseDialog()
ucrBase.clsRsyntax.SetFunction("apply")
ucrReceiverForRowStatistics.Selector = ucrSelectorForRowStats
ucrReceiverForRowStatistics.SetMeAsReceiver()
ucrReceiverForRowStatistics.SetDataType("numeric")
ucrBase.clsRsyntax.AddParameter("MARGIN", 1)

ucrInputcboRowSummary.SetPrefix("RowSummary")
ucrInputcboRowSummary.SetItemsTypeAsColumns()
ucrInputcboRowSummary.SetDefaultTypeAsColumn()
ucrInputcboRowSummary.SetDataFrameSelector(ucrSelectorForRowStats.ucrAvailableDataFrames)

ucrBase.iHelpTopicID = 45
cmdUserDefined.Enabled = False
End Sub


Private Sub ucrReceiverForRowStatistics_SelectionChanged() Handles ucrReceiverForRowStatistics.SelectionChanged
If Not ucrReceiverForRowStatistics.IsEmpty Then
Expand All @@ -64,28 +76,34 @@ Public Class dlgRowStats
TestOKEnabled()
End Sub



Private Sub Statistic_CheckedChanged(sender As Object, e As EventArgs) Handles rdoMean.CheckedChanged, rdoCount.CheckedChanged, rdoMaximum.CheckedChanged, rdoMinimum.CheckedChanged, rdoSum.CheckedChanged, rdoStandardDeviation.CheckedChanged
Private Sub Statistic_CheckedChanged(sender As Object, e As EventArgs) Handles rdoMean.CheckedChanged, rdoCount.CheckedChanged, rdoMaximum.CheckedChanged, rdoMinimum.CheckedChanged, rdoSum.CheckedChanged, rdoStandardDeviation.CheckedChanged, rdoNumberofMissing.CheckedChanged, rdoMedian.CheckedChanged, rdoMedian.CheckedChanged, rdoNumberofMissing.CheckedChanged
If rdoMean.Checked = True Then
ucrBase.clsRsyntax.AddParameter("FUN", "mean")
ElseIf rdoCount.Checked = True Then
ucrBase.clsRsyntax.AddParameter("FUN", "function(z) sum(!is.na(z))")
ElseIf rdoMaximum.Checked = True Then
ucrBase.clsRsyntax.AddParameter("FUN", "max")
ElseIf rdoMinimum.Checked = True Then
ucrBase.clsRsyntax.AddParameter("FUN", "min")
ElseIf rdoSum.Checked = True Then
ucrBase.clsRsyntax.AddParameter("FUN", "sum")
ElseIf rdoStandardDeviation.Checked = True Then
ucrBase.clsRsyntax.AddParameter("FUN", "sd")
Else
ucrBase.clsRsyntax.RemoveParameter("FUN")
ElseIf rdoMaximum.Checked = True Then
ucrBase.clsRsyntax.AddParameter("FUN", "max")
ElseIf rdoMinimum.Checked = True Then
ucrBase.clsRsyntax.AddParameter("FUN", "min")
ElseIf rdoSum.Checked = True Then
ucrBase.clsRsyntax.AddParameter("FUN", "sum")
ElseIf rdoStandardDeviation.Checked = True Then
ucrBase.clsRsyntax.AddParameter("FUN", "sd")
ElseIf rdoMedian.Checked = True Then
ucrBase.clsRsyntax.AddParameter("FUN", "median")
ElseIf rdoNumberofMissing.Checked = True Then
ucrBase.clsRsyntax.AddParameter("FUN", "function(z) sum(is.na(z))")
Else
ucrBase.clsRsyntax.RemoveParameter("FUN")
End If

End Sub

Private Sub ucrNewColumnNameSelector_Leave(sender As Object, e As EventArgs) Handles ucrNewColumnSelectorForRowStats.Leave
ucrBase.clsRsyntax.SetAssignTo(strAssignToName:=ucrNewColumnSelectorForRowStats.cboColumnName.Text, strTempDataframe:=ucrSelectorForRowStats.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempColumn:=ucrNewColumnSelectorForRowStats.cboColumnName.Text)
Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset
SetDefaults()
End Sub

Private Sub ucrInputcboRowSummary_NameChanged() Handles ucrInputcboRowSummary.NameChanged
ucrBase.clsRsyntax.SetAssignTo(strAssignToName:=ucrInputcboRowSummary.GetText, strTempDataframe:=ucrSelectorForRowStats.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempColumn:=ucrInputcboRowSummary.GetText)
End Sub
End Class
6 changes: 6 additions & 0 deletions instat/ucrInput.vb
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,10 @@ Public Class ucrInput
Public Overridable Function IsEmpty() As Boolean
Return True
End Function

Private Sub ucrInput_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not bUserTyped Then
SetDefaultName()
End If
End Sub
End Class
4 changes: 4 additions & 0 deletions instat/ucrInputComboBox.vb
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,8 @@ Public Class ucrInputComboBox
Return False
End If
End Function

Private Sub ucrInputComboBox_Load(sender As Object, e As EventArgs) Handles Me.Load
FillItemTypes()
End Sub
End Class

0 comments on commit fcd5ba1

Please sign in to comment.