Skip to content

Commit

Permalink
Merge pull request #122 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
updating master
  • Loading branch information
anastasia-mbithe authored Feb 24, 2023
2 parents ef48134 + 332c8c9 commit b57a722
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 94 deletions.
64 changes: 39 additions & 25 deletions instat/dlgStack.Designer.vb

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

52 changes: 21 additions & 31 deletions instat/dlgStack.vb
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ Public Class dlgStack
ucrChkStackMultipleSets.SetText("Stack Multiple Column Sets")
ucrChkStackMultipleSets.AddToLinkedControls(ucrNudNoSets, {True}, bNewLinkedHideIfParameterMissing:=True)
ucrChkStackMultipleSets.AddToLinkedControls(ucrFactorInto, {True}, bNewLinkedHideIfParameterMissing:=True)
ucrChkStackMultipleSets.AddToLinkedControls(ucrChkCarryColumns, {False}, bNewLinkedHideIfParameterMissing:=True)
ucrChkStackMultipleSets.AddToLinkedControls(ucrChkCarryAllColumns, {False}, bNewLinkedHideIfParameterMissing:=True)
ucrChkStackMultipleSets.AddToLinkedControls(ucrPnlCarryColumns, {False}, bNewLinkedHideIfParameterMissing:=True)
ucrChkStackMultipleSets.AddToLinkedControls(ucrInputValuesTo, {False}, bNewLinkedHideIfParameterMissing:=True)
ucrChkStackMultipleSets.AddToLinkedControls(ucrChkDropMissingValues, {False}, bNewLinkedHideIfParameterMissing:=True)
ucrChkStackMultipleSets.AddToLinkedControls(ucrChkDropPrefix, {False}, bNewLinkedHideIfParameterMissing:=True)
Expand All @@ -103,8 +102,10 @@ Public Class dlgStack
ucrFactorInto.SetRDefault("variable")
ucrFactorInto.SetLinkedDisplayControl(lblFactorInto)

ucrChkCarryColumns.SetText("Columns to Carry")
ucrChkCarryColumns.AddToLinkedControls(ucrReceiverColumnsToCarry, {True}, bNewLinkedHideIfParameterMissing:=True)
ucrPnlCarryColumns.AddRadioButton(rdoCarryAllColumns)
ucrPnlCarryColumns.AddRadioButton(rdoCarryColumns)
ucrPnlCarryColumns.AddParameterIsRFunctionCondition(rdoCarryAllColumns, "data")
ucrPnlCarryColumns.AddParameterIsROperatorCondition(rdoCarryColumns, "%>%")

ucrInputValuesTo.SetParameter(New RParameter(" values_to", 4))
ucrInputValuesTo.SetRDefault(Chr(34) & "value" & Chr(34))
Expand Down Expand Up @@ -161,10 +162,6 @@ Public Class dlgStack
ucrReceiverTextColumn.strSelectorHeading = "Characters"
ucrReceiverTextColumn.SetDataType("character")

ucrChkCarryAllColumns.SetText("Carry All Columns")
ucrChkCarryAllColumns.AddParameterIsROperatorCondition(True, "%>%", False)
ucrChkCarryAllColumns.AddParameterIsROperatorCondition(False, "%>%", True)

ucrChkDropPrefix.SetText("Drop Prefix:")
ucrChkDropPrefix.AddParameterPresentCondition(True, "names_prefix")
ucrChkDropPrefix.AddParameterPresentCondition(False, "names_prefix", False)
Expand All @@ -175,7 +172,7 @@ Public Class dlgStack
ucrInputToken.AddToLinkedControls(ucrInputPattern, {"Regex"}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)
ucrInputToken.AddToLinkedControls(ucrChkPunctuation, {"Words", "Tweets"}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)
ucrInputToken.AddToLinkedControls(ucrChkUrl, {"Tweets"}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)
ucrPnlStack.AddToLinkedControls({ucrChkCarryColumns, ucrChkCarryAllColumns}, {rdoPivotLonger}, bNewLinkedHideIfParameterMissing:=True)
ucrPnlStack.AddToLinkedControls(ucrPnlCarryColumns, {rdoPivotLonger}, bNewLinkedHideIfParameterMissing:=True)
ucrPnlStack.AddToLinkedControls({ucrReceiverTextColumn, ucrInputOutput, ucrInputToken, ucrInputFormat, ucrChkToLowerCase}, {rdoUnnest}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)
ucrPnlStack.AddToLinkedControls({ucrInputNamesTo, ucrChkDropMissingValues, ucrFactorInto, ucrInputValuesTo, ucrChkStackMultipleSets, ucrReceiverColumnsToBeStack}, {rdoPivotLonger}, bNewLinkedHideIfParameterMissing:=True, bNewLinkedAddRemoveParameter:=True)
ucrChkDropPrefix.AddToLinkedControls(ucrInputDropPrefix, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedHideIfParameterMissing:=True)
Expand Down Expand Up @@ -215,7 +212,7 @@ Public Class dlgStack

ucrSelectorStack.Reset()
ucrSaveNewDataName.Reset()
ucrChkCarryColumns.Checked = False 'Note: This checkbox doesn't read from R code therefore setting its default state automatically isn't straightforward as such!
rdoCarryAllColumns.Checked = True
ucrReceiverColumnsToBeStack.SetMeAsReceiver()

clsPivotLongerFunction.SetRCommand("pivot_longer")
Expand Down Expand Up @@ -280,7 +277,7 @@ Public Class dlgStack
ucrChkDropMissingValues.SetRCode(clsPivotLongerFunction, bReset)
ucrInputValuesTo.SetRCode(clsPivotLongerFunction, bReset)
ucrPnlStack.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset)
ucrChkCarryAllColumns.SetRCode(clsPivotLongerFunction, bReset)
ucrPnlCarryColumns.SetRCode(clsPivotLongerFunction, bReset)
ucrInputDropPrefix.SetRCode(clsPivotLongerFunction, bReset)
ucrChkDropPrefix.SetRCode(clsPivotLongerFunction, bReset)
ucrFactorInto.SetRCode(clsReshapeFunction, bReset)
Expand All @@ -300,7 +297,7 @@ Public Class dlgStack
If ucrReceiverColumnsToBeStack.IsEmpty OrElse Not ucrSaveNewDataName.IsComplete OrElse
ucrInputNamesTo.IsEmpty OrElse ucrInputValuesTo.IsEmpty OrElse
ucrFactorInto.IsEmpty OrElse
(ucrReceiverColumnsToCarry.IsEmpty AndAlso ucrChkCarryColumns.Checked) Then
(ucrReceiverColumnsToCarry.IsEmpty AndAlso rdoCarryColumns.Checked) Then
ucrBase.OKEnabled(False)
Else
ucrBase.OKEnabled(True)
Expand All @@ -310,7 +307,6 @@ Public Class dlgStack
AndAlso Not ucrReceiverFrequency.IsEmpty _
AndAlso ucrSaveNewDataName.IsComplete)
End If

End Sub

Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset
Expand Down Expand Up @@ -353,17 +349,16 @@ Public Class dlgStack
End If
End Sub

Private Sub ucrChkCarryColumns_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkCarryColumns.ControlValueChanged,
Private Sub CarryColumns_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrPnlCarryColumns.ControlValueChanged,
ucrReceiverColumnsToBeStack.ControlValueChanged, ucrReceiverColumnsToCarry.ControlValueChanged

If (ucrChangedControl Is ucrChkCarryColumns) Then
If (ucrChkCarryColumns.Checked) Then
ucrReceiverColumnsToCarry.SetMeAsReceiver()
Else
ucrReceiverColumnsToBeStack.SetMeAsReceiver()
End If
If rdoCarryColumns.Checked Then
ucrReceiverColumnsToCarry.Visible = True
ucrReceiverColumnsToCarry.SetMeAsReceiver()
Else
ucrReceiverColumnsToCarry.Visible = False
ucrReceiverColumnsToBeStack.SetMeAsReceiver()
End If
ucrChkCarryAllColumns.Enabled = Not ucrChkCarryColumns.Checked

clsSelectFunction.ClearParameters()

Expand All @@ -373,8 +368,7 @@ Public Class dlgStack
iPosition = iPosition + 1
Next

If ucrChkCarryColumns.Checked Then
ucrChkCarryAllColumns.Enabled = False
If rdoCarryColumns.Checked Then
For Each strColumn In ucrReceiverColumnsToCarry.GetVariableNamesAsList
If Not ucrReceiverColumnsToBeStack.GetVariableNamesAsList.Contains(strColumn) Then
clsSelectFunction.AddParameter(strColumn, strColumn, iPosition:=iPosition, bIncludeArgumentName:=False)
Expand All @@ -387,24 +381,20 @@ Public Class dlgStack
End Sub

Private Sub AddRemoveDataOrPipeOperator()
clsPivotLongerFunction.RemoveParameterByName(If(ucrChkCarryAllColumns.Checked _
, "%>%", "data"))
If ucrChkCarryAllColumns.Checked Then
clsPivotLongerFunction.RemoveParameterByName(If(rdoCarryAllColumns.Checked _
, "%>%", "data"))
If rdoCarryAllColumns.Checked Then
clsPivotLongerFunction.AddParameter("data", clsRFunctionParameter:=ucrSelectorStack.ucrAvailableDataFrames.clsCurrDataFrame, iPosition:=0)
Else
clsPivotLongerFunction.AddParameter("%>%", clsROperatorParameter:=clsPipeOperator, iPosition:=0, bIncludeArgumentName:=False)
End If
End Sub

Private Sub ucrChkCarryAllColumns_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrChkCarryAllColumns.ControlValueChanged
AddRemoveDataOrPipeOperator()
End Sub

Private Sub CoreControls_ControlContentesChanged(ucrChangedControl As ucrCore) Handles ucrReceiverColumnsToBeStack.ControlContentsChanged,
ucrInputNamesTo.ControlContentsChanged, ucrInputValuesTo.ControlContentsChanged, ucrSaveNewDataName.ControlContentsChanged,
ucrInputOutput.ControlContentsChanged, ucrReceiverTextColumn.ControlContentsChanged, ucrInputToken.ControlContentsChanged,
ucrInputDropPrefix.ControlContentsChanged, ucrFactorInto.ControlContentsChanged, ucrPnlStack.ControlContentsChanged,
ucrInputFormat.ControlContentsChanged, ucrInputPattern.ControlContentsChanged, ucrChkCarryColumns.ControlContentsChanged,
ucrInputFormat.ControlContentsChanged, ucrInputPattern.ControlContentsChanged,
ucrReceiverColumnsToCarry.ControlContentsChanged, ucrChkDropMissingValues.ControlContentsChanged, ucrChkDropPrefix.ControlContentsChanged,
ucrChkStackMultipleSets.ControlContentsChanged, ucrReceiverFrequency.ControlContentsChanged, ucrReceiverExpand.ControlContentsChanged
TestOKEnabled()
Expand Down
Loading

0 comments on commit b57a722

Please sign in to comment.