Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved the displays of the lists and column type header #8015

Merged
merged 19 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions instat/Model/DataFrame/clsDataFramePage.vb
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ Public Class clsDataFramePage
' Structured columns e.g. "circular" are coded with "(S)"
ElseIf strHeaderType.Contains("circular") Then
columnHeader.strTypeShortCode = "(S)"
ElseIf strHeaderType.Contains("list") Then
columnHeader.strTypeShortCode = "(LT)"
' Types of data for specific Application areas e.g. survival are coded with "(A)"
' No examples implemented yet.
'ElseIf strType.Contains() Then
Expand Down
8 changes: 6 additions & 2 deletions instat/Model/RCommand/clsPrepareFunctionsForGrids.vb
Original file line number Diff line number Diff line change
Expand Up @@ -317,20 +317,24 @@ Public Class clsPrepareFunctionsForGrids
''' <param name="strColumnName"></param>
''' <param name="strRowText"></param>
''' <param name="bWithQuotes"></param>
Public Sub ReplaceValueInData(strNewValue As String, strColumnName As String, strRowText As String, bWithQuotes As Boolean)
''' <param name="bListOfVector"></param>
Public Sub ReplaceValueInData(strNewValue As String, strColumnName As String, strRowText As String, bWithQuotes As Boolean, Optional bListOfVector As Boolean = False, Optional bAddOutputInInternalViewer As Boolean = True)
Dim clsReplaceValue As New RFunction
'trim white space from ends of value
strNewValue = strNewValue.Trim()
clsReplaceValue.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$replace_value_in_data")
clsReplaceValue.AddParameter("data_name", Chr(34) & _strDataFrame & Chr(34))
clsReplaceValue.AddParameter("col_name", Chr(34) & strColumnName & Chr(34))
clsReplaceValue.AddParameter("rows", Chr(34) & strRowText & Chr(34))
If bListOfVector Then
strNewValue = "list(c(" & strNewValue & "))"
End If
If bWithQuotes Then
clsReplaceValue.AddParameter("new_value", Chr(34) & strNewValue & Chr(34))
Else
clsReplaceValue.AddParameter("new_value", strNewValue)
End If
_RLink.RunScript(clsReplaceValue.ToScript(), strComment:="Replace Value In Data")
_RLink.RunScript(clsReplaceValue.ToScript(), strComment:="Replace Value In Data", bAddOutputInInternalViewer:=bAddOutputInInternalViewer)
End Sub

''' <summary>
Expand Down
21 changes: 20 additions & 1 deletion instat/UserControls/DataGrid/ReoGrid/ucrDataViewReoGrid.vb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,26 @@ Public Class ucrDataViewReoGrid
strRowNames = dataFrame.DisplayedRowNames()
For i = 0 To grdData.CurrentWorksheet.Rows - 1
For j = 0 To grdData.CurrentWorksheet.Columns - 1
grdData.CurrentWorksheet(row:=i, col:=j) = dataFrame.DisplayedData(i, j)
Dim strData As String = dataFrame.DisplayedData(i, j)
'numeric(0) returns a numeric vector of length 0,
'so when you add anything to it you get the same result (it's basically a numeric NULL)
'in this case we will display the data as NA
If grdData.CurrentWorksheet.ColumnHeaders.Item(j).Text.Contains("(LT)") Then
If strData = "numeric(0)" Then
strData = "NA"
ElseIf strData.Contains("(") Then
'get the string in the brackets e.g c(1,2,3), so with this we will display 1,2,3 in the grid.
'see issue #7947 for more information
strData = strData.Split(New String() {"(", ")"}, StringSplitOptions.None)(1)
'If strData = "" Then
' dataFrame.clsPrepareFunctions.ReplaceValueInData("NA", grdData.CurrentWorksheet.ColumnHeaders.Item(j).Text.Replace("(LT)", "").Trim(),
' grdData.CurrentWorksheet.RowHeaders.Item(i).Text.Trim(), bWithQuotes:=False, bAddOutputInInternalViewer:=False)
'End If
Else
strData = strData.Replace(":", ",")
End If
End If
grdData.CurrentWorksheet(row:=i, col:=j) = strData
Next
grdData.CurrentWorksheet.RowHeaders.Item(i).Text = strRowNames(i)
grdData.CurrentWorksheet.RowHeaders(i).TextColor = textColour
Expand Down
3 changes: 2 additions & 1 deletion instat/static/InstatObject/R/data_object_R6.R
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ DataSheet$set("public", "get_data_frame", function(convert_to_character = FALSE,
} else {
out <- out[1:max_rows, ]
}
}
}

if(convert_to_character) {
decimal_places = self$get_variables_metadata(property = signif_figures_label, column = names(out), error_if_no_property = FALSE)
scientific_notation = self$get_variables_metadata(property = scientific_label, column = names(out), error_if_no_property = FALSE)
Expand Down
11 changes: 10 additions & 1 deletion instat/ucrDataView.vb
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ Public Class ucrDataView
Dim dblValue As Double
Dim iValue As Integer
Dim bWithQuotes As Boolean
Dim bListOfVector = False

If strNewValue = "NA" Then
bWithQuotes = False
Expand All @@ -352,6 +353,14 @@ Public Class ucrDataView
MsgBox("Invalid value: '" & strNewValue & "'" & Environment.NewLine & "This column is: integer. Values must be integer.", MsgBoxStyle.Exclamation, "Invalid Value")
Exit Sub
End If
Case "list"
If strNewValue.Split(",").All(Function(x) Integer.TryParse(x, iValue) Or Double.TryParse(x, dblValue) Or Trim(x) = "NA") Then
bWithQuotes = False
bListOfVector = strNewValue.Contains(",")
Else
MsgBox("Invalid value: '" & strNewValue & "'" & Environment.NewLine & "This column is: a list of numeric and numeric vector. Values must be numeric.", MsgBoxStyle.Exclamation, "Invalid Value")
Exit Sub
End If
Case Else
If Double.TryParse(strNewValue, dblValue) OrElse strNewValue = "TRUE" OrElse strNewValue = "FALSE" Then
bWithQuotes = False
Expand All @@ -361,7 +370,7 @@ Public Class ucrDataView
End Select
End If
StartWait()
GetCurrentDataFrameFocus().clsPrepareFunctions.ReplaceValueInData(strNewValue, strColumnName, strRowText, bWithQuotes)
GetCurrentDataFrameFocus().clsPrepareFunctions.ReplaceValueInData(strNewValue, strColumnName, strRowText, bWithQuotes, bListOfVector)
EndWait()
End Sub

Expand Down