Skip to content

Commit

Permalink
Merge pull request #182 from africanmathsinitiative/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
Vitalis95 authored Oct 26, 2023
2 parents 6e92ca0 + 536a3c4 commit 7332c83
Show file tree
Hide file tree
Showing 22 changed files with 573 additions and 822 deletions.
12 changes: 9 additions & 3 deletions instat/Model/DataFrame/clsDataBook.vb
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,10 @@ Public Class clsDataBook
End If
'if data not refreshed successfully, remove the data frame from the data book
If Not dataFrame.RefreshData() Then
MessageBox.Show("Error: Could not retrieve data frame:" & strDataFrameName & " from R" &
Environment.NewLine & "Data displayed in spreadsheet may not be up to date." &
Environment.NewLine & "We strongly suggest restarting R-Instat before continuing.",
MessageBox.Show("Error: Sorry R-Instat can not retrieve the: " & strDataFrameName & " data from R.",
"Cannot retrieve data", MessageBoxButtons.OK, MessageBoxIcon.Warning)
_lstDataFrames.Remove(dataFrame)
DeleteDataFrames(strDataFrameName)
End If
Next
If lstOfCurrentRDataFrameNames.Count = _lstDataFrames.Count Then
Expand Down Expand Up @@ -189,5 +188,12 @@ Public Class clsDataBook
Return listOfDataFrames
End Function

Private Sub DeleteDataFrames(strDataName As String)
Dim clsDeleteFunction As New RFunction
clsDeleteFunction.SetRCommand(_RLink.strInstatDataObject & "$delete_dataframes")
clsDeleteFunction.AddParameter("data_names", Chr(34) & strDataName & Chr(34))
_RLink.RunScript(clsDeleteFunction.ToScript(), strComment:="Delete DataFrame(s)")
End Sub

End Class

6 changes: 5 additions & 1 deletion instat/Model/Output/clsOutputElement.vb
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,15 @@ Public Class clsOutputElement
_strOutput = strOutput
End Sub

''' <summary>
''' <summary>
''' Gets formatted R Script, split into R Script Elements
''' </summary>
''' <returns></returns>
Public ReadOnly Property FormattedRScript As List(Of clsRScriptElement)

'todo.
'this function may end up being called multiple times. For long scripts initialising clsRScript And getting tokens takes lot of time. You can test this effect by pasting new data frame that has many columns.
'should the operation of getting tokens be done just once then stored to be reused f need be?
Get
Dim _lstRScriptElements As New List(Of clsRScriptElement)
Try
Expand Down
2 changes: 1 addition & 1 deletion instat/UserControl/ucrOutputPage.vb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Public Class ucrOutputPage
'whether it's just a script output

'todo. temporary fix. Output element should always have an R script
If outputElement.FormattedRScript IsNot Nothing Then
If outputElement.Script IsNot Nothing Then
AddNewScript(outputElement)
End If

Expand Down
8 changes: 5 additions & 3 deletions instat/UserControls/DataGrid/ReoGrid/ucrDataViewReoGrid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,12 @@ Public Class ucrDataViewReoGrid
' Check if the row index is within the valid range
If rowNumber >= 0 AndAlso rowNumber < currWorkSheet.RowCount Then
If bApplyToRows Then
' Apply the row style to the entire row
currWorkSheet.Cells(rowNumber, colIndex).Style.BackColor = color
For i As Integer = 0 To currWorkSheet.ColumnCount - 1
' Apply the row style to the entire row
currWorkSheet.Cells(rowNumber, i).Style.BackColor = color
Next
Else
currWorkSheet.SetRangeStyles(New RangePosition(rowNumber, 0, 1, colIndex), rowStyle)
currWorkSheet.Cells(rowNumber, colIndex).Style.BackColor = color
End If
End If
Next
Expand Down
10 changes: 6 additions & 4 deletions instat/dlgName.vb
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ Public Class dlgName
ucrPnlCase.AddRadioButton(rdoReplace, "stringr::str_replace")

ucrPnlSelectData.SetParameter(New RParameter("data", 0))
ucrPnlSelectData.AddRadioButton(rdoWholeDataFrame, "x")
ucrPnlSelectData.AddRadioButton(rdoSelectedColumn, "y")
ucrPnlSelectData.AddRadioButton(rdoWholeDataFrame)
ucrPnlSelectData.AddRadioButton(rdoSelectedColumn)
ucrPnlSelectData.AddParameterValuesCondition(rdoWholeDataFrame, "checked", "whole")
ucrPnlSelectData.AddParameterValuesCondition(rdoSelectedColumn, "checked", "selected")

ucrReceiverColumns.SetParameter(New RParameter(".cols", 6))
ucrReceiverColumns.Selector = ucrSelectVariables
Expand Down Expand Up @@ -179,7 +181,7 @@ Public Class dlgName
clsNewLabelDataframeFunction.SetRCommand("data.frame")

clsDummyFunction.AddParameter("checked", "FALSE", iPosition:=0)
clsDummyFunction.AddParameter("data", "x", iPosition:=1)
clsDummyFunction.AddParameter("checked", "whole", iPosition:=1)

clsDefaultRFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$rename_column_in_data")
clsDefaultRFunction.AddParameter("type", Chr(34) & "single" & Chr(34), iPosition:=4)
Expand Down Expand Up @@ -219,11 +221,11 @@ Public Class dlgName
If bReset Then
ucrPnlCase.SetRCode(clsDefaultRFunction, bReset)
ucrInputReplace.SetRCode(clsDefaultRFunction, bReset)
ucrChkIncludeVariable.SetRCode(clsDummyFunction, bReset)
End If
ucrInputCase.SetRCode(clsDefaultRFunction, bReset)
ucrNudAbbreviate.SetRCode(clsDefaultRFunction, bReset)
ucrPnlOptions.SetRCode(clsDefaultRFunction, bReset)
ucrChkIncludeVariable.SetRCode(clsDummyFunction, bReset)
ucrInputBy.SetRCode(clsDefaultRFunction, bReset)
ucrPnlSelectData.SetRCode(clsDummyFunction, bReset)
End Sub
Expand Down
240 changes: 235 additions & 5 deletions instat/dlgPasteNewColumns.Designer.vb

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

Loading

0 comments on commit 7332c83

Please sign in to comment.