Skip to content

Commit

Permalink
Merge pull request #21 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
fetching latest copy
  • Loading branch information
maxwellfundi committed May 10, 2016
2 parents 8c8fc93 + 2965956 commit ded0878
Show file tree
Hide file tree
Showing 15 changed files with 478 additions and 192 deletions.
9 changes: 3 additions & 6 deletions instat/clsGridLink.vb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ Public Class clsGridLink
strDataName = lstDataNames.AsCharacter(i)
If (bGrdDataExists And frmMain.clsRLink.clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$get_data_changed(data_name = " & Chr(34) & strDataName & Chr(34) & ")").AsLogical(0)) Then
frmMain.clsRLink.clsEngine.Evaluate(strDataName & "<-" & frmMain.clsRLink.strInstatDataObject & "$get_data_frame(" & Chr(34) & strDataName & Chr(34) & ", convert_to_character = TRUE, include_hidden_columns = FALSE)")
dfTemp = frmMain.clsRLink.clsEngine.GetSymbol(strDataName).AsCharacterMatrix
dfTemp = frmMain.clsRLink.clsEngine.GetSymbol(strDataName).AsCharacterMatrix
FillSheet(dfTemp, strDataName, grdData, bInstatObjectDataFrame:=True, bIncludeDataTypes:=True, iNewPosition:=i)
frmEditor.lstColumnNames = dfTemp.ColumnNames()
frmMain.clsRLink.clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$set_data_frames_changed(" & Chr(34) & strDataName & Chr(34) & ", FALSE)")
End If
If (bGrdVariablesMetadataExists And frmMain.clsRLink.clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$get_variables_metadata_changed(" & Chr(34) & strDataName & Chr(34) & ")").AsLogical(0)) Then
Expand Down Expand Up @@ -211,12 +212,8 @@ Public Class clsGridLink
fillWorkSheet.ColumnHeaders(k).Text = dfTemp.ColumnNames(k) & " (D)"
Case "logical"
fillWorkSheet.ColumnHeaders(k).Text = dfTemp.ColumnNames(k) & " (l)"
Case "numeric"
fillWorkSheet.ColumnHeaders(k).Text = dfTemp.ColumnNames(k) & " (n)"
Case "integer"
fillWorkSheet.ColumnHeaders(k).Text = dfTemp.ColumnNames(k) & " (n)"
Case Else
fillWorkSheet.ColumnHeaders(k).Text = dfTemp.ColumnNames(k) & " (U)"
fillWorkSheet.ColumnHeaders(k).Text = dfTemp.ColumnNames(k)
End Select
Next
Else
Expand Down
66 changes: 53 additions & 13 deletions instat/clsRFunction.vb
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,24 @@ Public Class RFunction
Public strAssignToModel As String
Public bToBeAssigned As Boolean = False
Public bIsAssigned As Boolean = False
Private bAssignToIsPrefix As Boolean = False

Public Sub SetRCommand(strTemp As String)
strRCommand = strTemp
bIsAssigned = False
End Sub

Public Sub SetAssignTo(strTemp As String, Optional strTempDataframe As String = "", Optional strTempColumn As String = "", Optional strTempModel As String = "")
Public Sub SetAssignTo(strTemp As String, Optional strTempDataframe As String = "", Optional strTempColumn As String = "", Optional strTempModel As String = "", Optional bAssignToIsPrefix As Boolean = False)
strAssignTo = strTemp
If Not strTempDataframe = "" Then
strAssignToDataFrame = strTempDataframe
If Not strTempColumn = "" Then
strAssignToColumn = strTempColumn
End If
ElseIf Not strTempModel = "" Then
strAssignToModel = strTempModel
ElseIf Not strTempModel = "" Then
strAssignToModel = strTempModel
End If
Me.bAssignToIsPrefix = bAssignToIsPrefix
bToBeAssigned = True
bIsAssigned = False
End Sub
Expand All @@ -55,6 +57,13 @@ Public Class RFunction
Public Function ToScript(Optional ByRef strScript As String = "") As String
Dim strTemp As String = ""
Dim i As Integer
Dim clsAddColumns As New RFunction
Dim clsGetColumns As New RFunction
Dim clsAddData As New RFunction
Dim clsGetData As New RFunction
Dim clsAddModels As New RFunction
Dim clsGetModels As New RFunction
Dim clsDataList As New RFunction

If bIsAssigned Then
Return (strAssignTo)
Expand All @@ -64,7 +73,7 @@ Public Class RFunction

For i = 0 To clsParameters.Count - 1
If i > 0 Then
strTemp = strTemp & ","
strTemp = strTemp & ", "
End If
strTemp = strTemp & clsParameters(i).ToScript(strScript)
Next
Expand All @@ -75,20 +84,51 @@ Public Class RFunction
End If
strScript = strScript & strAssignTo & " <- " & strTemp & vbCrLf
If Not strAssignToDataFrame = "" Then
If Not strAssignToColumn = "" Then
strScript = strScript & frmMain.clsRLink.strInstatDataObject & "$add_columns_to_data(data_name = " & Chr(34) & strAssignToDataFrame & Chr(34) & ", col_name = " & Chr(34) & strAssignToColumn & Chr(34) & ", col_data = " & strAssignTo & ")" & vbCrLf
strAssignTo = frmMain.clsRLink.strInstatDataObject & "$get_column_from_data(data_name = " & Chr(34) & strAssignToDataFrame & Chr(34) & ", col_name = " & Chr(34) & strAssignToColumn & Chr(34) & ")"
If Not strAssignToColumn = "" Then
clsAddColumns.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$add_columns_to_data")
clsAddColumns.AddParameter("data_name", Chr(34) & strAssignToDataFrame & Chr(34))
clsAddColumns.AddParameter("col_name", Chr(34) & strAssignToColumn & Chr(34))
clsAddColumns.AddParameter("col_data", strAssignTo)
If bAssignToIsPrefix Then
clsAddColumns.AddParameter("use_col_name_as_prefix", "TRUE")
Else
If frmMain.clsInstatOptions.bIncludeRDefaultParameters Then
clsAddColumns.AddParameter("use_col_name_as_prefix", "FALSE")
End If
End If
strScript = strScript & clsAddColumns.ToScript() & vbCrLf

clsGetColumns.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_columns_from_data")
clsGetColumns.AddParameter("data_name", Chr(34) & strAssignToDataFrame & Chr(34))
clsGetColumns.AddParameter("col_name", Chr(34) & strAssignToColumn & Chr(34))
strAssignTo = clsGetColumns.ToScript()

bIsAssigned = True
bToBeAssigned = False
Else
strScript = strScript & frmMain.clsRLink.strInstatDataObject & "$import_data(data_tables = list(" & strAssignToDataFrame & "=" & strAssignTo & "))" & vbCrLf
strAssignTo = frmMain.clsRLink.strInstatDataObject & "$get_data_frame(data_name = " & Chr(34) & strAssignToDataFrame & Chr(34) & ")"
Else
clsAddData.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$import_data")
clsDataList.SetRCommand("list")
clsDataList.AddParameter(strAssignToDataFrame, strAssignTo)
clsAddData.AddParameter("data_tables", clsRFunctionParameter:=clsDataList)
strScript = strScript & clsAddData.ToScript() & vbCrLf

clsGetData.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_data_frame")
clsGetData.AddParameter("data_name", Chr(34) & strAssignToDataFrame & Chr(34))
strAssignTo = clsGetData.ToScript()

bIsAssigned = True
bToBeAssigned = False
End If
ElseIf Not strAssignToModel = "" Then
strScript = strScript & frmMain.clsRLink.strInstatDataObject & "$add_model(model_name = " & Chr(34) & strAssignToModel & Chr(34) & ", model = " & strAssignTo & ")" & vbCrLf
strAssignTo = frmMain.clsRLink.strInstatDataObject & "$get_models( model_name = " & Chr(34) & strAssignToModel & Chr(34) & ")"
ElseIf Not strAssignToModel = "" Then
clsAddModels.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$add_model")
clsAddModels.AddParameter("model_name", Chr(34) & strAssignToModel & Chr(34))
clsAddModels.AddParameter("model", strAssignTo)
strScript = strScript & clsAddModels.ToScript() & vbCrLf

clsGetModels.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_models")
clsGetModels.AddParameter("model_name", Chr(34) & strAssignToModel & Chr(34))
strAssignTo = clsGetModels.ToScript()

bIsAssigned = True
bToBeAssigned = False
End If
Expand Down
3 changes: 2 additions & 1 deletion instat/clsROperator.vb
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ Public Class ROperator
Public bToBeAssigned As Boolean = False
Public bIsAssigned As Boolean = False
Public bForceIncludeOperation As Boolean = True
Public bAssignToIsPrefix As Boolean = False

Public Sub SetOperation(strTemp As String, Optional bBracketsTemp As Boolean = True)
strOperation = strTemp
bBrackets = bBracketsTemp
bIsAssigned = False
End Sub

Public Sub SetAssignTo(strTemp As String, Optional strTempDataframe As String = "", Optional strTempColumn As String = "", Optional strTempModel As String = "")
Public Sub SetAssignTo(strTemp As String, Optional strTempDataframe As String = "", Optional strTempColumn As String = "", Optional strTempModel As String = "", Optional bAssignToIsPrefix As Boolean = False)
strAssignTo = strTemp
If Not strTempDataframe = "" Then
strAssignToDataFrame = strTempDataframe
Expand Down
6 changes: 3 additions & 3 deletions instat/clsRSyntax.vb
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ Public Class RSyntax
bUseBaseOperator = True
End Sub

Public Sub SetAssignTo(strAssignToName As String, Optional strTempDataframe As String = "", Optional strTempColumn As String = "", Optional strTempModel As String = "")
Public Sub SetAssignTo(strAssignToName As String, Optional strTempDataframe As String = "", Optional strTempColumn As String = "", Optional strTempModel As String = "", Optional bAssignToIsPrefix As Boolean = False)
If bUseBaseOperator Then
clsBaseOperator.SetAssignTo(strAssignToName)
clsBaseOperator.SetAssignTo(strAssignToName, bAssignToIsPrefix:=bAssignToIsPrefix)
End If
If bUseBaseFunction Then
clsBaseFunction.SetAssignTo(strAssignToName, strTempDataframe, strTempColumn, strTempModel)
clsBaseFunction.SetAssignTo(strAssignToName, strTempDataframe, strTempColumn, strTempModel, bAssignToIsPrefix)
End If
End Sub

Expand Down
45 changes: 41 additions & 4 deletions instat/dlgDeleteDescriptive.Designer.vb

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

Loading

0 comments on commit ded0878

Please sign in to comment.