Skip to content

Commit

Permalink
Merge pull request #173 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
update branch
  • Loading branch information
AlexSananka authored Aug 18, 2017
2 parents 53f8530 + 2265954 commit 17e6696
Show file tree
Hide file tree
Showing 34 changed files with 1,249 additions and 698 deletions.
195 changes: 119 additions & 76 deletions instat/clsGridLink.vb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions instat/clsRLink.vb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Public Class RLink
If strLine.Trim(vbLf).Count > 0 Then
RunScript(strScript:=strLine.Trim(vbLf), iCallType:=iCallType, strComment:=strComment, bSeparateThread:=bSeparateThread, bSilent:=True)
End If
strComment = ""
Next
bInstatObjectExists = True
End Sub
Expand Down
1 change: 1 addition & 0 deletions instat/dlgBarAndPieChart.vb
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ Public Class dlgBarAndPieChart
clsPieAesFunction = New RFunction

ucrBarChartSelector.Reset()
ucrBarChartSelector.SetGgplotFunction(clsBaseOperator)
ucrFactorReceiver.SetMeAsReceiver()
ucrSaveBar.Reset()
bResetSubdialog = True
Expand Down
19 changes: 19 additions & 0 deletions instat/dlgConvertColumns.vb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Public Class dlgConvertColumns
Public bFirstLoad As Boolean = True
Public bToFactorOnly As Boolean = False
Private bReset As Boolean = True
Private bUseSelectedColumn As Boolean = False
Private strSelectedColumn As String = ""
Public strSelectedDataFrame As String = ""
Private clsDefaultFunction As New RFunction

Private Sub dlgConvertColumns_Load(sender As Object, e As EventArgs) Handles Me.Load
Expand All @@ -32,6 +35,10 @@ Public Class dlgConvertColumns
SetDefaults()
End If
SetRCodeForControls(bReset)
bReset = False
If bUseSelectedColumn Then
SetDefaultColumn()
End If
ReopenDialog()
TestOKEnabled()
End Sub
Expand Down Expand Up @@ -95,6 +102,18 @@ Public Class dlgConvertColumns
ucrBase.clsRsyntax.SetBaseRFunction(clsDefaultFunction)
End Sub

Public Sub SetCurrentColumn(strColumn As String, strDataFrame As String)
strSelectedColumn = strColumn
strSelectedDataFrame = strDataFrame
bUseSelectedColumn = True
End Sub

Private Sub SetDefaultColumn()
ucrSelectorDataFrameColumns.ucrAvailableDataFrames.cboAvailableDataFrames.SelectedItem = strSelectedDataFrame
ucrReceiverColumnsToConvert.Add(strSelectedColumn, strSelectedDataFrame)
bUseSelectedColumn = False
End Sub

Private Sub SetRCodeForControls(bReset As Boolean)
SetRCode(Me, ucrBase.clsRsyntax.clsBaseFunction, bReset)
End Sub
Expand Down
1 change: 1 addition & 0 deletions instat/dlgCumulativeDistribution.vb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Public Class dlgCumulativeDistribution
clsRggplotFunction = New RFunction

ucrCumDistSelector.Reset()
ucrCumDistSelector.SetGgplotFunction(clsBaseOperator)
ucrCumDistSelector.Focus()
ucrSaveCumDist.Reset()
sdgPlots.Reset()
Expand Down
1 change: 1 addition & 0 deletions instat/dlgDotPlot.vb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ Public Class dlgDotPlot
clsRaesFunction = New RFunction

ucrDotPlotSelector.Reset()
ucrDotPlotSelector.SetGgplotFunction(clsBaseOperator)
ucrSaveDotPlot.Reset()
bResetSubdialog = True
bResetDotLayerSubdialog = True
Expand Down
10 changes: 7 additions & 3 deletions instat/dlgDuplicateColumns.vb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ Public Class dlgDuplicateColumns
Public bFirstLoad As Boolean = True
Private bReset As Boolean = True
Private clsDefaultFunction As New RFunction
Dim bUseSelectedColumn As Boolean = False
Dim strSelectedColumn As String = ""
Dim strSelectedDataFrame As String = ""
Public strSelectedDataFrame As String = ""
Private bUseSelectedColumn As Boolean = False
Private strSelectedColumn As String = ""

Private Sub dlgCopySheet_Load(sender As Object, e As EventArgs) Handles Me.Load
If bFirstLoad Then
Expand All @@ -48,6 +48,10 @@ Public Class dlgDuplicateColumns
End If
SetRCodeforControls(bReset)
bReset = False
If bUseSelectedColumn Then
SetDefaultColumn()
End If
TestOKEnabled()
autoTranslate(Me)
End Sub

Expand Down
40 changes: 20 additions & 20 deletions instat/dlgDuplicatesConstructed.vb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Imports instat.Translations
Public Class dlgDuplicatesConstructed
Private bReset As Boolean = True
Private bFirstLoad As Boolean = True
Private clsDuplicate2, clsDuplicated As New RFunction
Private clsDuplicated2, clsDuplicated As New RFunction

Private Sub dlgDuplicatesConstructed_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If bFirstLoad Then
InitialiseDialog()
Expand Down Expand Up @@ -70,34 +71,33 @@ Public Class dlgDuplicatesConstructed

Private Sub SetDefaults()
clsDuplicated = New RFunction
clsDuplicate2 = New RFunction
clsDuplicated2 = New RFunction

ucrNewColumnName.Reset()
ucrSelectorDuplicateswithVariables.Reset()
ucrReceiverMultipleForDuplicates.SetMeAsReceiver()

clsDuplicated.SetRCommand("duplicated")
clsDuplicated.AddParameter("x", clsRFunctionParameter:=ucrSelectorDuplicateswithVariables.ucrAvailableDataFrames.clsCurrDataFrame, iPosition:=0)

clsDuplicate2.SetPackageName("questionr")
clsDuplicate2.SetRCommand("duplicated2")
clsDuplicate2.AddParameter("x", frmMain.clsRLink.strInstatDataObject & "$get_data_frame", iPosition:=0)

SetBaseFunction()
DataFrameParameter()
clsDuplicated2.SetPackageName("questionr")
clsDuplicated2.SetRCommand("duplicated2")
clsDuplicated2.AddParameter("x", clsRFunctionParameter:=ucrSelectorDuplicateswithVariables.ucrAvailableDataFrames.clsCurrDataFrame, iPosition:=0)

ucrBase.clsRsyntax.SetAssignTo(strAssignToName:=ucrNewColumnName.GetText, strTempDataframe:=ucrSelectorDuplicateswithVariables.ucrAvailableDataFrames.cboAvailableDataFrames.Text, strTempColumn:=ucrNewColumnName.GetText)
ucrBase.clsRsyntax.SetBaseRFunction(clsDuplicate2)
ucrBase.clsRsyntax.SetBaseRFunction(clsDuplicated2)
End Sub

Private Sub SetRCodeForControls(bReset As Boolean)
ucrReceiverMultipleForDuplicates.AddAdditionalCodeParameterPair(clsDuplicate2, ucrReceiverMultipleForDuplicates.GetParameter, iAdditionalPairNo:=1)
ucrSelectorDuplicateswithVariables.AddAdditionalCodeParameterPair(clsDuplicate2, ucrSelectorDuplicateswithVariables.GetParameter, iAdditionalPairNo:=1)
ucrNewColumnName.AddAdditionalRCode(clsDuplicate2, 1)
ucrReceiverMultipleForDuplicates.AddAdditionalCodeParameterPair(clsDuplicated2, ucrReceiverMultipleForDuplicates.GetParameter, iAdditionalPairNo:=1)
ucrSelectorDuplicateswithVariables.AddAdditionalCodeParameterPair(clsDuplicated2, ucrSelectorDuplicateswithVariables.GetParameter, iAdditionalPairNo:=1)
ucrNewColumnName.AddAdditionalRCode(clsDuplicated2, 1)

ucrSelectorDuplicateswithVariables.SetRCode(clsDuplicated, bReset)
ucrReceiverMultipleForDuplicates.SetRCode(clsDuplicated, bReset)
ucrNewColumnName.SetRCode(clsDuplicated, bReset)
ucrPnlDuplicates.SetRCode(ucrBase.clsRsyntax.clsBaseFunction, bReset)
ucrPnlOptions.SetRCode(clsDuplicate2, bReset)
ucrPnlOptions.SetRCode(clsDuplicated, bReset)
End Sub

Private Sub TestOKEnabled()
Expand All @@ -118,26 +118,26 @@ Public Class dlgDuplicatesConstructed
TestOKEnabled()
End Sub

Private Sub ucrPnlOptions_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrPnlOptions.ControlValueChanged, ucrPnlDuplicates.ControlValueChanged
DataFrameParameter()
Private Sub ucrPnlOptions_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrPnlOptions.ControlValueChanged
SetDataFrameOrColumns()
End Sub

Private Sub DataFrameParameter()
Private Sub SetDataFrameOrColumns()
If rdoDataFrame.Checked Then
ucrSelectorDuplicateswithVariables.SetVariablesVisible(False)
clsDuplicated.AddParameter("x", clsRFunctionParameter:=ucrSelectorDuplicateswithVariables.ucrAvailableDataFrames.clsCurrDataFrame, iPosition:=0)
clsDuplicate2.AddParameter("x", clsRFunctionParameter:=ucrSelectorDuplicateswithVariables.ucrAvailableDataFrames.clsCurrDataFrame, iPosition:=0)
clsDuplicated2.AddParameter("x", clsRFunctionParameter:=ucrSelectorDuplicateswithVariables.ucrAvailableDataFrames.clsCurrDataFrame, iPosition:=0)
ElseIf rdoSelectedVariables.Checked Then
ucrSelectorDuplicateswithVariables.SetVariablesVisible(True)
clsDuplicated.AddParameter("x", clsRFunctionParameter:=ucrReceiverMultipleForDuplicates.GetVariables, iPosition:=0)
clsDuplicate2.AddParameter("x", clsRFunctionParameter:=ucrReceiverMultipleForDuplicates.GetVariables, iPosition:=0)
clsDuplicated2.AddParameter("x", clsRFunctionParameter:=ucrReceiverMultipleForDuplicates.GetVariables, iPosition:=0)
Else
End If
End Sub

Private Sub SetBaseFunction()
If rdoAllDuplicateCases.Checked Then
ucrBase.clsRsyntax.SetBaseRFunction(clsDuplicate2)
ucrBase.clsRsyntax.SetBaseRFunction(clsDuplicated2)
ElseIf rdoDuplicatesOnly.Checked Then
ucrBase.clsRsyntax.SetBaseRFunction(clsDuplicated)
End If
Expand All @@ -148,7 +148,7 @@ Public Class dlgDuplicatesConstructed
End Sub

Private Sub ucrSelectorDuplicateswithVariables_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrSelectorDuplicateswithVariables.ControlValueChanged
DataFrameParameter()
SetDataFrameOrColumns()
End Sub

Private Sub ucrCoreControls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrNewColumnName.ControlContentsChanged, ucrReceiverMultipleForDuplicates.ControlContentsChanged, ucrSelectorDuplicateswithVariables.ControlContentsChanged, ucrPnlOptions.ControlContentsChanged
Expand Down
30 changes: 22 additions & 8 deletions instat/dlgExportDataset.vb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Public Class dlgExportDataset
Dim bFirstLoad As Boolean = True
Private bReset As Boolean = True
Private clsDefaultFunction As New RFunction
Private strCurrentFileName As String

Private Sub dlgExportDataset_Load(sender As Object, e As EventArgs) Handles Me.Load
autoTranslate(Me)
Expand Down Expand Up @@ -75,15 +76,24 @@ Public Class dlgExportDataset
End Sub

Private Sub cmdBrowse_Click(sender As Object, e As EventArgs) Handles cmdBrowse.Click
Dim dlgSave As New SaveFileDialog
dlgSave.Title = "Export File Dialog"
dlgSave.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory
dlgSave.Filter = "Comma separated file (*.csv)|*.csv|Excel files (*.xlsx)|*.xlsx|TAB-separated data (*.tsv)|*.tsv|Pipe-separated data (*.psv)|*.psv|Feather r / Python interchange format (*.feather)|*.feather|Fixed-Width format data (*.fwf)|*.fwf|Serialized r objects (*.rds)|*.rds|Saved r objects (*.RData)|*.RData|JSON(*.json)|*.json|YAML(*.yml)|*.yml|Stata(*.dta)|*.dta|SPSS(*.sav)|*.sav|XBASE database files (*.dbf)|*.dbf| Weka Attribute - Relation File Format (*.arff)|*.arff|r syntax object (*.R)|*.R|Xml(*.xml)|*.xml|HTML(*.html)|*.html"
If dlgSave.ShowDialog = DialogResult.OK Then
If dlgSave.FileName <> "" Then
ucrInputExportFile.SetName(Path.GetFullPath(dlgSave.FileName).ToString.Replace("\", "/"))
Using dlgSave As New SaveFileDialog
dlgSave.Title = "Export File Dialog"
dlgSave.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory
If strCurrentFileName <> "" Then
dlgSave.FileName = Path.GetFileNameWithoutExtension(strCurrentFileName)
dlgSave.InitialDirectory = Path.GetDirectoryName(strCurrentFileName)
Else
dlgSave.FileName = ucrAvailableSheets.cboAvailableDataFrames.Text
dlgSave.InitialDirectory = frmMain.clsInstatOptions.strWorkingDirectory
End If
End If
dlgSave.Filter = "Comma separated file (*.csv)|*.csv|Excel files (*.xlsx)|*.xlsx|TAB-separated data (*.tsv)|*.tsv|Pipe-separated data (*.psv)|*.psv|Feather r / Python interchange format (*.feather)|*.feather|Fixed-Width format data (*.fwf)|*.fwf|Serialized r objects (*.rds)|*.rds|Saved r objects (*.RData)|*.RData|JSON(*.json)|*.json|YAML(*.yml)|*.yml|Stata(*.dta)|*.dta|SPSS(*.sav)|*.sav|XBASE database files (*.dbf)|*.dbf| Weka Attribute - Relation File Format (*.arff)|*.arff|r syntax object (*.R)|*.R|Xml(*.xml)|*.xml|HTML(*.html)|*.html"
If dlgSave.ShowDialog = DialogResult.OK Then
If dlgSave.FileName <> "" Then
ucrInputExportFile.SetName(Path.GetFullPath(dlgSave.FileName).ToString.Replace("\", "/"))
End If
strCurrentFileName = dlgSave.FileName
End If
End Using
End Sub

Private Sub ucrInputExportFile_Click(sender As Object, e As EventArgs) Handles ucrInputExportFile.Click
Expand All @@ -93,4 +103,8 @@ Public Class dlgExportDataset
Private Sub ucrInputExportFile_ControlContentsChanged(ucrchangedControl As ucrCore) Handles ucrInputExportFile.ControlContentsChanged, ucrAvailableSheets.ControlContentsChanged
TestOkEnabled()
End Sub

Private Sub ucrAvailableSheets_DataFrameChanged(sender As Object, e As EventArgs, strPrevDataFrame As String) Handles ucrAvailableSheets.DataFrameChanged
strCurrentFileName = ""
End Sub
End Class
Loading

0 comments on commit 17e6696

Please sign in to comment.