Skip to content

Commit

Permalink
Merge pull request #23 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
Pulling changes from the main
  • Loading branch information
deaspo committed Jan 26, 2016
2 parents 64706fb + c3d8c1a commit bd5a563
Show file tree
Hide file tree
Showing 5 changed files with 176 additions and 60 deletions.
81 changes: 81 additions & 0 deletions instat/My Project/Resources.Designer.vb

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

27 changes: 27 additions & 0 deletions instat/My Project/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -934,4 +934,31 @@
<data name="Yes" xml:space="preserve">
<value>Yes</value>
</data>
<data name="Bernouli" xml:space="preserve">
<value>Bernouli</value>
</data>
<data name="Binomial" xml:space="preserve">
<value>Binomial</value>
</data>
<data name="Exponential1" xml:space="preserve">
<value>Exponential</value>
</data>
<data name="Extreme_Value" xml:space="preserve">
<value>Extreme Value</value>
</data>
<data name="Geometric1" xml:space="preserve">
<value>Geometric</value>
</data>
<data name="Normal1" xml:space="preserve">
<value>Normal</value>
</data>
<data name="Poisson" xml:space="preserve">
<value>Poisson</value>
</data>
<data name="Uniform" xml:space="preserve">
<value>Uniform</value>
</data>
<data name="Weibull" xml:space="preserve">
<value>Weibull</value>
</data>
</root>
21 changes: 16 additions & 5 deletions instat/dlgImportDataset.vb
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,26 @@ Public Class dlgImportDataset
ucrBase.clsRsyntax.AddParameter("sep", "Comma")

cboDecimal.Text = "Period"
ucrBase.clsRsyntax.AddParameter("dec", "Period")
ucrBase.clsRsyntax.AddParameter("dec", Chr(34) & "." & Chr(34))

cboQuote.Text = "Double quote"
ucrBase.clsRsyntax.AddParameter("quote", "\" & Chr(34))
ucrBase.clsRsyntax.AddParameter("quote", Chr(34) & "\" & Chr(34) & Chr(34))

cboComment.Text = "None"
ucrBase.clsRsyntax.AddParameter("comment.Char", "None")

ucrBase.clsRsyntax.SetAssignTo(txtName.Text, strTempDataframe:=txtName.Text)

txtNAStrings.Text = "NA"
ucrBase.clsRsyntax.AddParameter("na.strings", "NA")

End Sub

Public Sub SetName(strName As String)
strName = Replace(strName, " ", "")
strName = Replace(strName, "-", "")
txtName.Text = strName
ucrBase.clsRsyntax.SetAssignTo(txtName.Text, strTempDataframe:=txtName.Text)
End Sub

Private Sub txtName_Leave(sender As Object, e As EventArgs) Handles txtName.Leave
ucrBase.clsRsyntax.SetAssignTo(txtName.Text, strTempDataframe:=txtName.Text)
End Sub
Expand All @@ -56,6 +61,7 @@ Public Class dlgImportDataset

Private Sub cboRowNames_Leave(sender As Object, e As EventArgs) Handles cboRowNames.Leave
If cboRowNames.Text <> "Automatic" Then

ucrBase.clsRsyntax.AddParameter("row.names", cboRowNames.Text)
End If
End Sub
Expand All @@ -65,7 +71,12 @@ Public Class dlgImportDataset
End Sub

Private Sub cboDecimal_Leave(sender As Object, e As EventArgs) Handles cboDecimal.Leave
ucrBase.clsRsyntax.AddParameter("dec", cboDecimal.Text)
Select Case cboDecimal.Text
Case "Period"
ucrBase.clsRsyntax.AddParameter("dec", Chr(34) & "." & Chr(34))
Case "Comma"
ucrBase.clsRsyntax.AddParameter("dec", Chr(34) & "," & Chr(34))
End Select
End Sub

Private Sub cboQuote_Leave(sender As Object, e As EventArgs) Handles cboQuote.Leave
Expand Down
21 changes: 14 additions & 7 deletions instat/frmMain.vb
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,10 @@ Public Class frmMain
frmScript.MdiParent = Me
frmVariables.MdiParent = Me
frmMetaData.MdiParent = Me
' TODO get these to be in correct position without changing dockstyle
' so that it doesn't mess with cascade etc.
'frmCommand.Dock = DockStyle.Right
'frmEditor.Dock = DockStyle.Left

frmCommand.Show()
frmEditor.Show()
Me.LayoutMdi(MdiLayout.TileVertical)

'Setting the properties of R Interface
clsRLink.SetLog(frmLog.txtLog)
Expand Down Expand Up @@ -582,11 +579,21 @@ Public Class frmMain
Dim strFileExt As String

pair = OpenFromFileDialog()
strFileExt = Path.GetExtension(pair.Value)
'pair.key is the File Name
'pair.value is the File Path

' TODO Probably remove LoadData sub in clsRLink once all opening is done through dialogs
If Not IsNothing(pair.Key) Then
clsRLink.LoadData(pair.Key, pair.Value, strFileExt)
strFileExt = Path.GetExtension(pair.Value)
Select Case strFileExt
Case ".RDS"
'TODO create dialog to do this
clsRLink.LoadData(pair.Key, pair.Value, strFileExt)
Case ".csv"
dlgImportDataset.SetName(pair.Key)
dlgImportDataset.ShowDialog()
End Select
End If
clsRLink.LoadData(pair.Key, pair.Value, strFileExt)

'Dim kvpFile As KeyValuePair(Of String, String)
'Dim clsRsyntax As New RSyntax
Expand Down
86 changes: 38 additions & 48 deletions instat/ucrDistributions.vb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ Public Class ucrDistributions
Dim clsBernouliDist As New Distribution
Dim clsBinomialDist As New Distribution
Dim clsPoissonDist As New Distribution
Dim clsAutogressiveDist As New Distribution

' Normal distribution
clsNormalDist.strNameTag = "Normal"
Expand Down Expand Up @@ -110,77 +109,68 @@ Public Class ucrDistributions
clsGeometricDist.strPFunctionName = "pgeom"
clsGeometricDist.strQFunctionName = "qgeom"
clsGeometricDist.strDFunctionName = "dgeom"
clsGeometricDist.AddParameter("prob", "Probability")
clsGeometricDist.AddParameter("prob", "Probability", 1)
lstAllDistributions.Add(clsGeometricDist)

' Extreme Value Distribution
clsExtremeValueDist.strNameTag = "Extreme_Value"
clsGeometricDist.strRFunctionName = ""
clsGeometricDist.strPFunctionName = ""
clsGeometricDist.strQFunctionName = ""
clsGeometricDist.strDFunctionName = ""
clsExtremeValueDist.strRFunctionName = "rgev"
clsExtremeValueDist.strPFunctionName = "pgev"
clsExtremeValueDist.strQFunctionName = "qgev"
clsExtremeValueDist.strDFunctionName = "dgev"
clsExtremeValueDist.AddParameter("mode", "Mode")
clsExtremeValueDist.AddParameter("scale", "Scale")
lstAllDistributions.Add(clsExtremeValueDist)

' Weibull Distribution
clsWeibullDist.strNameTag = "Weibull"
clsWeibullDist.strRFunctionName = ""
clsWeibullDist.strPFunctionName = ""
clsWeibullDist.strQFunctionName = ""
clsWeibullDist.strDFunctionName = ""
clsWeibullDist.AddParameter("mean", "Mean")
clsWeibullDist.AddParameter("shape", "Shape")
clsWeibullDist.strRFunctionName = "rweibull"
clsWeibullDist.strPFunctionName = "pweibull"
clsWeibullDist.strQFunctionName = "qweibull"
clsWeibullDist.strDFunctionName = "dweibull"
clsWeibullDist.AddParameter("shape", "shape")
clsWeibullDist.AddParameter("scale", "scale", 1)
lstAllDistributions.Add(clsWeibullDist)

'Uniform Distribution
clsUniformDist.strNameTag = ""
clsUniformDist.strRFunctionName = ""
clsUniformDist.strPFunctionName = ""
clsUniformDist.strQFunctionName = ""
clsUniformDist.strDFunctionName = ""
clsUniformDist.AddParameter("a", "a")
clsUniformDist.AddParameter("b", "b")
clsUniformDist.strNameTag = "Uniform"
clsUniformDist.strRFunctionName = "runif"
clsUniformDist.strPFunctionName = "punif"
clsUniformDist.strQFunctionName = "qunif"
clsUniformDist.strDFunctionName = "dunif"
clsUniformDist.AddParameter("a", "a", 0)
clsUniformDist.AddParameter("b", "b", 1)
lstAllDistributions.Add(clsUniformDist)


'bernouli Distribution
clsBernouliDist.strNameTag = ""
clsBernouliDist.strRFunctionName = ""
clsBernouliDist.strPFunctionName = ""
clsBernouliDist.strQFunctionName = ""
clsBernouliDist.strDFunctionName = ""
clsBernouliDist.AddParameter("prob", "Probability")
'Bernouli Distribution
clsBernouliDist.strNameTag = "Bernouli"
clsBernouliDist.strRFunctionName = "rbern"
clsBernouliDist.strPFunctionName = "pbern"
clsBernouliDist.strQFunctionName = "qbern"
clsBernouliDist.strDFunctionName = "dbern"
clsBernouliDist.AddParameter("prob", "Probability", 0.5)
lstAllDistributions.Add(clsBernouliDist)

'Binomial Distribution
clsBinomialDist.strNameTag = ""
clsBinomialDist.strRFunctionName = ""
clsBinomialDist.strPFunctionName = ""
clsBinomialDist.strQFunctionName = ""
clsBinomialDist.strDFunctionName = ""
clsBinomialDist.AddParameter("number", "Number")
clsBinomialDist.AddParameter("prob", "Probability")
clsBinomialDist.strNameTag = "Binomial"
clsBinomialDist.strRFunctionName = "rbinom"
clsBinomialDist.strPFunctionName = "pbinom"
clsBinomialDist.strQFunctionName = "qbinom"
clsBinomialDist.strDFunctionName = "dbinom"
clsBinomialDist.AddParameter("number", "Number", 1)
clsBinomialDist.AddParameter("prob", "Probability", 0.5)
lstAllDistributions.Add(clsBinomialDist)

'poisson Distribution
clsPoissonDist.strNameTag = ""
clsPoissonDist.strRFunctionName = ""
clsPoissonDist.strPFunctionName = ""
clsPoissonDist.strQFunctionName = ""
clsPoissonDist.strDFunctionName = ""
clsPoissonDist.AddParameter("mean", "Mean")
clsPoissonDist.strNameTag = "Poisson"
clsPoissonDist.strRFunctionName = "rpois"
clsPoissonDist.strPFunctionName = "ppois"
clsPoissonDist.strQFunctionName = "qpois"
clsPoissonDist.strDFunctionName = "dpois"
clsPoissonDist.AddParameter("mean", "Mean", 1)
lstAllDistributions.Add(clsPoissonDist)

'Autogressive Distribution
clsAutogressiveDist.strNameTag = ""
clsAutogressiveDist.strRFunctionName = ""
clsAutogressiveDist.strPFunctionName = ""
clsAutogressiveDist.strQFunctionName = ""
clsAutogressiveDist.strDFunctionName = ""
clsAutogressiveDist.AddParameter("mean", "Mean")
clsAutogressiveDist.AddParameter("st.", "St. Dev")
lstAllDistributions.Add(clsAutogressiveDist)
bDistributionsSet = True
End Sub
Public Event cboDistributionsIndexChanged(sender As Object, e As EventArgs)
Expand Down

0 comments on commit bd5a563

Please sign in to comment.