diff --git a/instat/clsGridLink.vb b/instat/clsGridLink.vb index 0e4910a1cb9..4d06371503e 100644 --- a/instat/clsGridLink.vb +++ b/instat/clsGridLink.vb @@ -60,32 +60,66 @@ Public Class clsGridLink Dim dfTemp As CharacterMatrix Dim strDataName As String Dim shtTemp As Worksheet + Dim clsDataChanged As New RFunction + Dim clsMetadataChanged As New RFunction + Dim clsVariablesMetadataChanged As New RFunction + Dim clsGetDataNames As New RFunction + Dim clsGetDataFrame As New RFunction + Dim clsFilterApplied As New RFunction + Dim clsSetDataFramesChanged As New RFunction + Dim clsGetVariablesMetadata As New RFunction + Dim clsSetVariablesMetadataChanged As New RFunction + Dim clsGetCombinedMetadata As New RFunction + Dim clsSetMetadataChanged As New RFunction + clsDataChanged.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_data_changed") + clsMetadataChanged.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_metadata_changed") + clsVariablesMetadataChanged.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_variables_metadata_changed") + clsGetDataNames.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_data_names") + clsGetDataFrame.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_data_frame") + clsGetDataFrame.AddParameter("convert_to_character", "TRUE") + clsGetDataFrame.AddParameter("include_hidden_columns", "FALSE") + clsGetDataFrame.AddParameter("use_current_filter", "TRUE") + clsFilterApplied.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$filter_applied") + clsSetDataFramesChanged.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$set_data_frames_changed") + clsGetVariablesMetadata.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_variables_metadata") + clsGetVariablesMetadata.AddParameter("convert_to_character", "TRUE") + clsSetVariablesMetadataChanged.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$set_variables_metadata_changed") + clsGetCombinedMetadata.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_combined_metadata") + clsSetMetadataChanged.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$set_metadata_changed") + If Not frmMain.clsRLink.bInstatObjectExists Then Exit Sub - bRDataChanged = frmMain.clsRLink.clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$get_data_changed()").AsLogical(0) - bRMetadataChanged = frmMain.clsRLink.clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$get_metadata_changed()").AsLogical(0) - bRVariablesMetadataChanged = frmMain.clsRLink.clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$get_variables_metadata_changed()").AsLogical(0) + bRDataChanged = frmMain.clsRLink.RunInternalScriptGetValue(clsDataChanged.ToScript()).AsLogical(0) + bRMetadataChanged = frmMain.clsRLink.RunInternalScriptGetValue(clsMetadataChanged.ToScript()).AsLogical(0) + bRVariablesMetadataChanged = frmMain.clsRLink.RunInternalScriptGetValue(clsVariablesMetadataChanged.ToScript()).AsLogical(0) If (bGrdDataExists And (bGrdDataChanged Or bRDataChanged)) Or (bGrdVariablesMetadataExists And (bGrdVariablesMetadataChanged Or bRVariablesMetadataChanged)) Then - lstDataNames = frmMain.clsRLink.clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$get_data_names()").AsList + lstDataNames = frmMain.clsRLink.RunInternalScriptGetValue(clsGetDataNames.ToScript()).AsList For i = 0 To lstDataNames.Length - 1 strDataName = lstDataNames.AsCharacter(i) - If (bGrdDataExists AndAlso 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, use_current_filter = TRUE)") - dfTemp = frmMain.clsRLink.clsEngine.GetSymbol(strDataName).AsCharacterMatrix() - If frmMain.clsRLink.RunInternalScriptGetValue(frmMain.clsRLink.strInstatDataObject & "$filter_applied(data_name = " & Chr(34) & strDataName & Chr(34) & ")").AsLogical(0) Then + clsDataChanged.AddParameter("data_name", Chr(34) & strDataName & Chr(34)) + If (bGrdDataExists AndAlso frmMain.clsRLink.RunInternalScriptGetValue(clsDataChanged.ToScript()).AsLogical(0)) Then + clsGetDataFrame.AddParameter("data_name", Chr(34) & strDataName & Chr(34)) + dfTemp = frmMain.clsRLink.RunInternalScriptGetValue(clsGetDataFrame.ToScript()).AsCharacterMatrix + clsFilterApplied.AddParameter("data_name", Chr(34) & strDataName & Chr(34)) + If frmMain.clsRLink.RunInternalScriptGetValue(clsFilterApplied.ToScript()).AsLogical(0) Then FillSheet(dfTemp, strDataName, grdData, bInstatObjectDataFrame:=True, bIncludeDataTypes:=True, iNewPosition:=i, bFilterApplied:=True, bCheckFreezeColumns:=True) Else - FillSheet(dfTemp, strDataName, grdData, bInstatObjectDataFrame:=True, bIncludeDataTypes:=True, iNewPosition:=i, bCheckFreezeColumns:=True) + FillSheet(dfTemp, strDataName, grdData, bInstatObjectDataFrame:=True, bIncludeDataTypes:=True, iNewPosition:=i, bFilterApplied:=False, bCheckFreezeColumns:=True) End If frmEditor.SetColumnNames(strDataName, dfTemp.ColumnNames()) - frmMain.clsRLink.clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$set_data_frames_changed(" & Chr(34) & strDataName & Chr(34) & ", FALSE)") + clsSetDataFramesChanged.AddParameter("data_name", Chr(34) & strDataName & Chr(34)) + clsSetDataFramesChanged.AddParameter("new_val", "FALSE") + frmMain.clsRLink.RunInternalScript(clsSetDataFramesChanged.ToScript()) End If - If (bGrdVariablesMetadataExists And frmMain.clsRLink.clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$get_variables_metadata_changed(" & Chr(34) & strDataName & Chr(34) & ")").AsLogical(0)) Then - dfTemp = frmMain.clsRLink.clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$get_variables_metadata(" & Chr(34) & strDataName & Chr(34) & ", convert_to_character = TRUE)").AsCharacterMatrix() + clsVariablesMetadataChanged.AddParameter("data_name", Chr(34) & strDataName & Chr(34)) + If (bGrdVariablesMetadataExists AndAlso frmMain.clsRLink.RunInternalScriptGetValue(clsVariablesMetadataChanged.ToScript()).AsLogical(0)) Then + dfTemp = frmMain.clsRLink.RunInternalScriptGetValue(clsGetVariablesMetadata.ToScript()).AsCharacterMatrix() FillSheet(dfTemp, strDataName, grdVariablesMetadata) - frmMain.clsRLink.clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$set_variables_metadata_changed(" & Chr(34) & strDataName & Chr(34) & ", FALSE)") + clsSetVariablesMetadataChanged.AddParameter("data_name", Chr(34) & strDataName & Chr(34)) + clsSetVariablesMetadataChanged.AddParameter("new_val", "TRUE") + frmMain.clsRLink.RunInternalScript(clsSetVariablesMetadataChanged.ToScript()) End If Next 'delete old sheets @@ -132,12 +166,14 @@ Public Class clsGridLink End If If bGrdMetadataExists And (bGrdMetadataChanged Or bRMetadataChanged) Then - dfTemp = frmMain.clsRLink.clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$get_combined_metadata(convert_to_character = TRUE)").AsCharacterMatrix() + clsGetCombinedMetadata.AddParameter("convert_to_character", "True") + dfTemp = frmMain.clsRLink.RunInternalScriptGetValue(clsGetCombinedMetadata.ToScript()).AsCharacterMatrix() FillSheet(dfTemp, "metadata", grdMetadata) - frmMain.clsRLink.clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$set_metadata_changed(new_val = FALSE)") + clsSetMetadataChanged.AddParameter("new_val", "TRUE") + frmMain.clsRLink.RunInternalScript(clsSetMetadataChanged.ToScript()) End If - frmMain.clsRLink.clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$data_objects_changed <- FALSE") + frmMain.clsRLink.RunInternalScript(frmMain.clsRLink.strInstatDataObject & "$data_objects_changed <- FALSE") If grdData.Worksheets.Count = 0 Then grdData.Visible = False diff --git a/instat/clsRLink.vb b/instat/clsRLink.vb index 72c7c1d90d3..389cbaad3ee 100644 --- a/instat/clsRLink.vb +++ b/instat/clsRLink.vb @@ -95,7 +95,10 @@ Public Class RLink Public Function GetDataFrameNames() As List(Of String) Dim chrDataFrameNames As CharacterVector Dim lstDataFrameNames As New List(Of String) - chrDataFrameNames = clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$get_data_names()").AsCharacter + Dim clsGetDataNames As New RFunction + + clsGetDataNames.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_data_names") + chrDataFrameNames = RunInternalScriptGetValue(clsGetDataNames.ToScript()).AsCharacter lstDataFrameNames.AddRange(chrDataFrameNames) Return lstDataFrameNames End Function @@ -103,7 +106,11 @@ Public Class RLink Public Function GetColumnNames(strDataFrameName As String) As List(Of String) Dim chrCurrColumns As CharacterVector Dim lstCurrColumns As New List(Of String) - chrCurrColumns = clsEngine.Evaluate(strInstatDataObject & "$get_column_names(" & Chr(34) & strDataFrameName & Chr(34) & ")").AsCharacter + Dim clsGetColumnNames As New RFunction + + clsGetColumnNames.SetRCommand(strInstatDataObject & "$get_column_names") + clsGetColumnNames.AddParameter("data_name", Chr(34) & strDataFrameName & Chr(34)) + chrCurrColumns = RunInternalScriptGetValue(clsGetColumnNames.ToScript()).AsCharacter lstCurrColumns.AddRange(chrCurrColumns) Return lstCurrColumns End Function @@ -124,47 +131,44 @@ Public Class RLink End Sub Public Sub FillColumnNames(strDataFrame As String, ByRef cboColumns As ComboBox) - Dim lstCurrColumns As List(Of String) - - If bInstatObjectExists AndAlso clsEngine IsNot Nothing Then - lstCurrColumns = GetColumnNames(strDataFrame) - cboColumns.Items.Clear() - cboColumns.Items.AddRange(lstCurrColumns.ToArray) - End If + Dim lstCurrColumns As List(Of String) + + lstCurrColumns = GetColumnNames(strDataFrame) + cboColumns.Items.Clear() + cboColumns.Items.AddRange(lstCurrColumns.ToArray) End Sub Public Sub FillColumnNames(strDataFrame As String, ByRef lstColumns As ListView) - Dim lstCurrColumns As List(Of String) - - If bInstatObjectExists AndAlso clsEngine IsNot Nothing Then - lstCurrColumns = GetColumnNames(strDataFrame) - lstColumns.Items.Clear() - If lstColumns.Columns.Count = 0 Then - lstColumns.Columns.Add("Available Data") - End If - For Each strTemp In lstCurrColumns - lstColumns.Items.Add(strTemp) - Next - lstColumns.Columns(0).Width = -2 - End If + Dim lstCurrColumns As List(Of String) + + lstCurrColumns = GetColumnNames(strDataFrame) + lstColumns.Items.Clear() + If lstColumns.Columns.Count = 0 Then + lstColumns.Columns.Add("Available Data") + End If + For Each strTemp In lstCurrColumns + lstColumns.Items.Add(strTemp) + Next + lstColumns.Columns(0).Width = -2 End Sub Public Function GetDefaultColumnNames(strPrefix As String) As GenericVector - Dim lstNextDefaults As GenericVector = Nothing - - If bInstatObjectExists Then - lstNextDefaults = clsEngine.Evaluate(strInstatDataObject & "$get_next_default_column_name(prefix = " & Chr(34) & strPrefix & Chr(34) & ")").AsList - End If + Dim lstNextDefaults As GenericVector = Nothing + Dim clsGetNextDefault As New RFunction + clsGetNextDefault.SetRCommand(strInstatDataObject & "$get_next_default_column_name") + clsGetNextDefault.AddParameter("prefix", Chr(34) & strPrefix & Chr(34)) + lstNextDefaults = RunInternalScriptGetValue(clsGetNextDefault.ToScript()).AsList Return lstNextDefaults End Function Public Function GetDefaultColumnNames(strPrefix As String, strDataFrameName As String) As String - Dim strNextDefault As String = "" - - If bInstatObjectExists Then - strNextDefault = clsEngine.Evaluate(strInstatDataObject & "$get_next_default_column_name(data_name = " & Chr(34) & strDataFrameName & Chr(34) & ", prefix = " & Chr(34) & strPrefix & Chr(34) & ")").AsCharacter(0) - End If + Dim strNextDefault As String = "" + Dim clsGetNextDefault As New RFunction + clsGetNextDefault.SetRCommand(strInstatDataObject & "$get_next_default_column_name") + clsGetNextDefault.AddParameter("prefix", Chr(34) & strPrefix & Chr(34)) + clsGetNextDefault.AddParameter("data_name", Chr(34) & strDataFrameName & Chr(34)) + strNextDefault = RunInternalScriptGetValue(clsGetNextDefault.ToScript()).AsCharacter(0) Return strNextDefault End Function @@ -270,16 +274,7 @@ Public Class RLink ' clear End Sub - - Public Function GetData(strLabel As String) As CharacterMatrix - - Me.clsEngine.Evaluate("temp<-" & strLabel) - Me.clsEngine.Evaluate("temp <- convert_to_character_matrix(temp)") - Return Me.clsEngine.GetSymbol("temp").AsCharacterMatrix() - - End Function - - Public Function RunInternalScriptGetValue(strScript As String, Optional strVariableName As String = ".temp_value", Optional bSilent As Boolean = True) As SymbolicExpression + Public Function RunInternalScriptGetValue(strScript As String, Optional strVariableName As String = ".temp_value", Optional bSilent As Boolean = False) As SymbolicExpression Dim expTemp As SymbolicExpression If clsEngine IsNot Nothing Then @@ -298,11 +293,11 @@ Public Class RLink Return expTemp End Function - Public Function RunInternalScriptGetOutput(strScript As String, Optional bSilent As Boolean = True) As CharacterVector + Public Function RunInternalScriptGetOutput(strScript As String, Optional bSilent As Boolean = False) As CharacterVector Dim chrTemp As CharacterVector Dim expTemp As SymbolicExpression - expTemp = RunInternalScriptGetValue("capture.output(" & strScript & ")") + expTemp = RunInternalScriptGetValue("capture.output(" & strScript & ")", bSilent = bSilent) Try chrTemp = expTemp.AsCharacter() Catch ex As Exception @@ -314,7 +309,7 @@ Public Class RLink Return chrTemp End Function - Public Function RunInternalScript(strScript As String, Optional strVariableName As String = "", Optional bSilent As Boolean = True) As Boolean + Public Function RunInternalScript(strScript As String, Optional strVariableName As String = "", Optional bSilent As Boolean = False) As Boolean If clsEngine IsNot Nothing Then Try If strVariableName <> "" Then @@ -336,29 +331,23 @@ Public Class RLink Public Function GetDefaultDataFrameName(strPrefix As String, Optional iStartIndex As Integer = 1, Optional bIncludeIndex As Boolean = True) As String Dim strTemp As String + Dim clsGetNextDataName As New RFunction + + clsGetNextDataName.SetRCommand(strInstatDataObject & "$get_next_default_dataframe_name") + clsGetNextDataName.AddParameter("prefix", Chr(34) & strPrefix & Chr(34)) + clsGetNextDataName.AddParameter("start_index", iStartIndex) If Not bInstatObjectExists Then CreateNewInstatObject() End If If bIncludeIndex Then - strTemp = clsEngine.Evaluate(strInstatDataObject & "$get_next_default_dataframe_name(prefix = " & Chr(34) & strPrefix & Chr(34) & ", include_index = TRUE, start_index =" & iStartIndex & ")").AsCharacter()(0) + clsGetNextDataName.AddParameter("include_index", "TRUE") Else - strTemp = clsEngine.Evaluate(strInstatDataObject & "$get_next_default_dataframe_name(prefix = " & Chr(34) & strPrefix & Chr(34) & ", include_index = FALSE, start_index =" & iStartIndex & ")").AsCharacter()(0) + clsGetNextDataName.AddParameter("include_index", "FALSE") End If - + strTemp = RunInternalScriptGetValue(clsGetNextDataName.ToScript()).AsCharacter(0) Return strTemp End Function - Public Function GetVar(strLabel As String) As CharacterVector - - Try - Return Me.clsEngine.Evaluate(strLabel).AsCharacter() - Catch - MsgBox(strLabel) - Return Nothing - End Try - - End Function - Public Sub CreateNewClimateObject() 'creates an instance of the climate object If Not bClimateObjectExists Then frmSetupLoading.Show() @@ -520,25 +509,31 @@ Public Class RLink Public Function DataFrameExists(strDataFrameName As String) As Boolean Dim bExists As Boolean - If clsEngine IsNot Nothing Then - bExists = clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$data_frame_exists(" & Chr(34) & strDataFrameName & Chr(34) & ")").AsLogical(0) - End If + Dim clsDataFrameExists As New RFunction + + clsDataFrameExists.SetRCommand(strInstatDataObject & "$data_frame_exists") + clsDataFrameExists.AddParameter("data_name", Chr(34) & strDataFrameName & Chr(34)) + bExists = RunInternalScriptGetValue(clsDataFrameExists.ToScript()).AsLogical(0) Return bExists End Function Public Function GetDataFrameLength(strDataFrameName As String) As Integer Dim intLength As Integer - If clsEngine IsNot Nothing Then - intLength = clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$get_data_frame_length(" & Chr(34) & strDataFrameName & Chr(34) & ")").AsInteger(0) - End If + Dim clsDataFrameLength As New RFunction + + clsDataFrameLength.SetRCommand(strInstatDataObject & "$get_data_frame_length") + clsDataFrameLength.AddParameter("data_name", Chr(34) & strDataFrameName & Chr(34)) + intLength = RunInternalScriptGetValue(clsDataFrameLength.ToScript()).AsInteger(0) Return intLength End Function Public Function GetDataFrameColumnCount(strDataFrameName As String) As Integer Dim intColumnCount As Integer - If clsEngine IsNot Nothing Then - intColumnCount = clsEngine.Evaluate(frmMain.clsRLink.strInstatDataObject & "$get_column_count(" & Chr(34) & strDataFrameName & Chr(34) & ")").AsInteger(0) - End If + Dim clsDataFrameColCount As New RFunction + + clsDataFrameColCount.SetRCommand(strInstatDataObject & "$get_column_count") + clsDataFrameColCount.AddParameter("data_name", Chr(34) & strDataFrameName & Chr(34)) + intColumnCount = RunInternalScriptGetValue(clsDataFrameColCount.ToScript()).AsInteger(0) Return intColumnCount End Function @@ -548,11 +543,11 @@ Public Class RLink Dim clsGetModelNames As New RFunction Dim expModelNames As SymbolicExpression - clsGetModelNames.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_model_names") + clsGetModelNames.SetRCommand(strInstatDataObject & "$get_model_names") If strDataFrameName <> "" Then clsGetModelNames.AddParameter("data_name", Chr(34) & strDataFrameName & Chr(34)) End If - expModelNames = RunInternalScriptGetValue(clsGetModelNames.ToScript()) + expModelNames = RunInternalScriptGetValue(clsGetModelNames.ToScript(), bSilent:=True) If Not expModelNames.Type = Internals.SymbolicExpressionType.Null Then chrModelNames = expModelNames.AsCharacter() If chrModelNames.Length > 0 Then @@ -568,9 +563,9 @@ Public Class RLink Dim lstFilterNames As New List(Of String) Dim clsGetFilterNames As New RFunction - clsGetFilterNames.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_filter_names") + clsGetFilterNames.SetRCommand(strInstatDataObject & "$get_filter_names") clsGetFilterNames.AddParameter("data_name", Chr(34) & strDataFrameName & Chr(34)) - expFilterNames = RunInternalScriptGetValue(clsGetFilterNames.ToScript()) + expFilterNames = RunInternalScriptGetValue(clsGetFilterNames.ToScript(), bSilent:=True) If Not expFilterNames.Type = Internals.SymbolicExpressionType.Null Then chrFilterNames = expFilterNames.AsCharacter() If chrFilterNames.Length > 0 Then @@ -586,11 +581,11 @@ Public Class RLink Dim clsGetGraphNames As New RFunction Dim expGraphNames As SymbolicExpression - clsGetGraphNames.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_graph_names") + clsGetGraphNames.SetRCommand(strInstatDataObject & "$get_graph_names") If strDataFrameName <> "" Then clsGetGraphNames.AddParameter("data_name", Chr(34) & strDataFrameName & Chr(34)) End If - expGraphNames = RunInternalScriptGetValue(clsGetGraphNames.ToScript()) + expGraphNames = RunInternalScriptGetValue(clsGetGraphNames.ToScript(), bSilent:=True) If Not expGraphNames.Type = Internals.SymbolicExpressionType.Null Then chrGraphNames = expGraphNames.AsCharacter() If chrGraphNames.Length > 0 Then @@ -601,9 +596,14 @@ Public Class RLink End Function Public Function GetDataType(strDataFrameName As String, strColumnName As String) As String - Dim strDataType As CharacterVector - strDataType = RunInternalScriptGetValue(frmMain.clsRLink.strInstatDataObject & "$get_data_type(data_name = " & Chr(34) & strDataFrameName & Chr(34) & ",col_name=" & Chr(34) & strColumnName & Chr(34) & ")").AsCharacter - Return strDataType(0) + Dim strDataType As String + Dim clsGetDataType As New RFunction + + clsGetDataType.SetRCommand(strInstatDataObject & "$get_data_type") + clsGetDataType.AddParameter("data_name", Chr(34) & strDataFrameName & Chr(34)) + clsGetDataType.AddParameter("col_name", Chr(34) & strColumnName & Chr(34)) + strDataType = RunInternalScriptGetValue(clsGetDataType.ToScript()).AsCharacter(0) + Return strDataType End Function End Class \ No newline at end of file diff --git a/instat/clsRSyntax.vb b/instat/clsRSyntax.vb index 1447876feb3..7d9c8c56071 100644 --- a/instat/clsRSyntax.vb +++ b/instat/clsRSyntax.vb @@ -273,4 +273,71 @@ Public Class RSyntax End Function + Public Function GetbIsAssigned() As Boolean + If bUseBaseFunction Then + Return clsBaseFunction.bIsAssigned + ElseIf bUseBaseOperator Then + Return clsBaseOperator.bIsAssigned + ElseIf bUseCommandString Then + Return bIsAssigned + Else + Return False + End If + End Function + + Public Function GetbToBeAssigned() As Boolean + If bUseBaseFunction Then + Return clsBaseFunction.bToBeAssigned + ElseIf bUseBaseOperator Then + Return clsBaseOperator.bToBeAssigned + ElseIf bUseCommandString Then + Return bToBeAssigned + Else + Return False + End If + End Function + + Public Function GetstrAssignTo() As String + If bUseBaseFunction Then + Return clsBaseFunction.strAssignTo + ElseIf bUseBaseOperator Then + Return clsBaseOperator.strAssignTo + ElseIf bUseCommandString Then + Return strAssignTo + Else + Return "" + End If + End Function + + ' WARNING These should only be called to reset previous values. + ' They should generally not be set directly. + Public Sub SetbIsAssigned(bNew As Boolean) + If bUseBaseFunction Then + clsBaseFunction.bIsAssigned = bNew + ElseIf bUseBaseOperator Then + clsBaseOperator.bIsAssigned = bNew + ElseIf bUseCommandString Then + bIsAssigned = bNew + End If + End Sub + + Public Sub SetbToBeAssigned(bNew As Boolean) + If bUseBaseFunction Then + clsBaseFunction.bToBeAssigned = bNew + ElseIf bUseBaseOperator Then + clsBaseOperator.bToBeAssigned = bNew + ElseIf bUseCommandString Then + bToBeAssigned = bNew + End If + End Sub + + Public Sub SetstrAssignTo(strNew As String) + If bUseBaseFunction Then + clsBaseFunction.strAssignTo = strNew + ElseIf bUseBaseOperator Then + clsBaseOperator.strAssignTo = strNew + ElseIf bUseCommandString Then + strAssignTo = strNew + End If + End Sub End Class \ No newline at end of file diff --git a/instat/clsRecentFiles.vb b/instat/clsRecentFiles.vb index 805faf96155..be7bbfaba39 100644 --- a/instat/clsRecentFiles.vb +++ b/instat/clsRecentFiles.vb @@ -49,15 +49,18 @@ Public Class clsRecentFiles End Sub Public Sub saveOnClose() + ' temp disabled to prevent error accessing file + ' TODO look up app config and Setting file as alternatives + 'saves the list of opened files on form close ' save MRU - delete existing files first - If File.Exists(MRUPath) Then - File.WriteAllText(MRUPath, "") - End If + 'If File.Exists(MRUPath) Then + 'File.WriteAllText(MRUPath, "") + 'End If ' write each item to the file... - For Each sPath As String In strListMRU - File.AppendAllText(MRUPath, sPath & vbCrLf) - Next + 'For Each sPath As String In strListMRU + 'File.AppendAllText(MRUPath, sPath & vbCrLf) + 'Next End Sub Public Sub addToMenu(ByVal tempObj As Object) diff --git a/instat/dlgCalculator.vb b/instat/dlgCalculator.vb index cab30b94ee4..632525c8428 100644 --- a/instat/dlgCalculator.vb +++ b/instat/dlgCalculator.vb @@ -75,7 +75,7 @@ Public Class dlgCalculator 'End Sub Private Sub AddText(strVar As String, Optional intStepsBack As Integer = 0, Optional bolInsertSelected As Boolean = False) - Dim intCurrCursorPosition As Integer + 'Dim intCurrCursorPosition As Integer 'Dim strSelectedText As String = txtCalcLine.SelectedText 'txtCalcLine.SelectedText = "" diff --git a/instat/dlgDescribeTwoVariable.Designer.vb b/instat/dlgDescribeTwoVariable.Designer.vb new file mode 100644 index 00000000000..7728b1cd921 --- /dev/null +++ b/instat/dlgDescribeTwoVariable.Designer.vb @@ -0,0 +1,52 @@ + _ +Partial Class dlgDescribeTwoVariable + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.UcrButtons1 = New instat.ucrButtons() + Me.SuspendLayout() + ' + 'UcrButtons1 + ' + Me.UcrButtons1.Location = New System.Drawing.Point(5, 201) + Me.UcrButtons1.Name = "UcrButtons1" + Me.UcrButtons1.Size = New System.Drawing.Size(410, 52) + Me.UcrButtons1.TabIndex = 0 + ' + 'dlgDescribeTwoVariable + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(419, 261) + Me.Controls.Add(Me.UcrButtons1) + Me.MaximizeBox = False + Me.MinimizeBox = False + Me.Name = "dlgDescribeTwoVariable" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent + Me.Tag = "Describe_Two_Variable" + Me.Text = "Describe Two Variable" + Me.ResumeLayout(False) + + End Sub + + Friend WithEvents UcrButtons1 As ucrButtons +End Class diff --git a/instat/dlgDescribeTwoVariable.fr-FR.resx b/instat/dlgDescribeTwoVariable.fr-FR.resx new file mode 100644 index 00000000000..9c9f69d752c --- /dev/null +++ b/instat/dlgDescribeTwoVariable.fr-FR.resx @@ -0,0 +1,15 @@ + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/instat/dlgDescribeTwoVariable.resx b/instat/dlgDescribeTwoVariable.resx new file mode 100644 index 00000000000..29dcb1b3a35 --- /dev/null +++ b/instat/dlgDescribeTwoVariable.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/instat/dlgDescribeTwoVariable.sw-KE.resx b/instat/dlgDescribeTwoVariable.sw-KE.resx new file mode 100644 index 00000000000..9c9f69d752c --- /dev/null +++ b/instat/dlgDescribeTwoVariable.sw-KE.resx @@ -0,0 +1,15 @@ + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/instat/dlgDescribeTwoVariable.vb b/instat/dlgDescribeTwoVariable.vb new file mode 100644 index 00000000000..08d60e26b44 --- /dev/null +++ b/instat/dlgDescribeTwoVariable.vb @@ -0,0 +1,21 @@ +' Instat-R +' Copyright (C) 2015 +' +' This program is free software: you can redistribute it and/or modify +' it under the terms of the GNU General Public License as published by +' the Free Software Foundation, either version 3 of the License, or +' (at your option) any later version. +' +' This program is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU General Public License for more details. +' +' You should have received a copy of the GNU General Public License k +' along with this program. If not, see . +Imports instat.Translations +Public Class dlgDescribeTwoVariable + Private Sub dlgDescribeTwoVariable_Load(sender As Object, e As EventArgs) Handles MyBase.Load + autoTranslate(Me) + End Sub +End Class \ No newline at end of file diff --git a/instat/dlgDescriptiveStatistics.Designer.vb b/instat/dlgDescriptiveStatistics.Designer.vb index d53c14c9b6f..3a756884093 100644 --- a/instat/dlgDescriptiveStatistics.Designer.vb +++ b/instat/dlgDescriptiveStatistics.Designer.vb @@ -1,171 +1,141 @@ - -Partial Class dlgDescriptiveStatistics - Inherits System.Windows.Forms.Form - - 'Form overrides dispose to clean up the component list. - - Protected Overrides Sub Dispose(ByVal disposing As Boolean) - Try - If disposing AndAlso components IsNot Nothing Then - components.Dispose() - End If - Finally - MyBase.Dispose(disposing) - End Try - End Sub - - 'Required by the Windows Form Designer - Private components As System.ComponentModel.IContainer - - 'NOTE: The following procedure is required by the Windows Form Designer - 'It can be modified using the Windows Form Designer. - 'Do not modify it using the code editor. - - Private Sub InitializeComponent() + +Partial Class dlgDescriptiveStatistics + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + + Private Sub InitializeComponent() Me.cmdStatistics = New System.Windows.Forms.Button() - Me.grpgraphics = New System.Windows.Forms.GroupBox() - Me.chkCumulativeFrequency = New System.Windows.Forms.CheckBox() - Me.chkBoxPlot = New System.Windows.Forms.CheckBox() - Me.chkStemAndLeaf = New System.Windows.Forms.CheckBox() - Me.chkGraphics = New System.Windows.Forms.CheckBox() - Me.ucrDataSelector = New instat.ucrSelectorAddRemove() - Me.ucrObjectReceiver = New instat.ucrReceiverSingle() + Me.ucrSelectorDescribeOneVar = New instat.ucrSelectorAddRemove() Me.lblSelectedVariable = New System.Windows.Forms.Label() - Me.ucrBase = New instat.ucrButtons() - Me.grpgraphics.SuspendLayout() + Me.ucrBaseDescribeOneVar = New instat.ucrButtons() + Me.chkSaveResult = New System.Windows.Forms.CheckBox() + Me.lblNewDataFrame = New System.Windows.Forms.Label() + Me.UcrInputTextBox1 = New instat.ucrInputTextBox() + Me.ucrReceiverDescribeOneVar = New instat.ucrReceiverMultiple() Me.SuspendLayout() ' 'cmdStatistics ' - Me.cmdStatistics.Location = New System.Drawing.Point(10, 165) + Me.cmdStatistics.Location = New System.Drawing.Point(325, 179) Me.cmdStatistics.Name = "cmdStatistics" - Me.cmdStatistics.Size = New System.Drawing.Size(104, 23) + Me.cmdStatistics.Size = New System.Drawing.Size(71, 23) Me.cmdStatistics.TabIndex = 90 - Me.cmdStatistics.Tag = "Choose_Statistics" - Me.cmdStatistics.Text = "Choose Statistics " + Me.cmdStatistics.Tag = "Statistics" + Me.cmdStatistics.Text = "Statistics " Me.cmdStatistics.UseVisualStyleBackColor = True ' - 'grpgraphics - ' - Me.grpgraphics.Controls.Add(Me.chkCumulativeFrequency) - Me.grpgraphics.Controls.Add(Me.chkBoxPlot) - Me.grpgraphics.Controls.Add(Me.chkStemAndLeaf) - Me.grpgraphics.Location = New System.Drawing.Point(93, 192) - Me.grpgraphics.Name = "grpgraphics" - Me.grpgraphics.Size = New System.Drawing.Size(314, 28) - Me.grpgraphics.TabIndex = 89 - Me.grpgraphics.TabStop = False - ' - 'chkCumulativeFrequency - ' - Me.chkCumulativeFrequency.AutoSize = True - Me.chkCumulativeFrequency.Location = New System.Drawing.Point(189, 5) - Me.chkCumulativeFrequency.Name = "chkCumulativeFrequency" - Me.chkCumulativeFrequency.Size = New System.Drawing.Size(128, 17) - Me.chkCumulativeFrequency.TabIndex = 61 - Me.chkCumulativeFrequency.Tag = "Cumulative_frequency" - Me.chkCumulativeFrequency.Text = "Cumulative frequency" - Me.chkCumulativeFrequency.UseVisualStyleBackColor = True - ' - 'chkBoxPlot - ' - Me.chkBoxPlot.AutoSize = True - Me.chkBoxPlot.Location = New System.Drawing.Point(112, 6) - Me.chkBoxPlot.Name = "chkBoxPlot" - Me.chkBoxPlot.Size = New System.Drawing.Size(65, 17) - Me.chkBoxPlot.TabIndex = 60 - Me.chkBoxPlot.Tag = "Box_Plot" - Me.chkBoxPlot.Text = "Box Plot" - Me.chkBoxPlot.UseVisualStyleBackColor = True - ' - 'chkStemAndLeaf - ' - Me.chkStemAndLeaf.AutoSize = True - Me.chkStemAndLeaf.Location = New System.Drawing.Point(7, 5) - Me.chkStemAndLeaf.Name = "chkStemAndLeaf" - Me.chkStemAndLeaf.Size = New System.Drawing.Size(91, 17) - Me.chkStemAndLeaf.TabIndex = 1 - Me.chkStemAndLeaf.Tag = "Stem_and_Leaf" - Me.chkStemAndLeaf.Text = "Stem and leaf" - Me.chkStemAndLeaf.UseVisualStyleBackColor = True - ' - 'chkGraphics - ' - Me.chkGraphics.AutoSize = True - Me.chkGraphics.Location = New System.Drawing.Point(10, 200) - Me.chkGraphics.Name = "chkGraphics" - Me.chkGraphics.Size = New System.Drawing.Size(71, 17) - Me.chkGraphics.TabIndex = 88 - Me.chkGraphics.Tag = "Graphics" - Me.chkGraphics.Text = "Graphics " - Me.chkGraphics.UseVisualStyleBackColor = True - ' - 'ucrDataSelector - ' - Me.ucrDataSelector.Location = New System.Drawing.Point(10, 10) - Me.ucrDataSelector.Margin = New System.Windows.Forms.Padding(0) - Me.ucrDataSelector.Name = "ucrDataSelector" - Me.ucrDataSelector.Size = New System.Drawing.Size(213, 147) - Me.ucrDataSelector.TabIndex = 92 - ' - 'ucrObjectReceiver - ' - Me.ucrObjectReceiver.Location = New System.Drawing.Point(235, 60) - Me.ucrObjectReceiver.Margin = New System.Windows.Forms.Padding(0) - Me.ucrObjectReceiver.Name = "ucrObjectReceiver" - Me.ucrObjectReceiver.Selector = Nothing - Me.ucrObjectReceiver.Size = New System.Drawing.Size(120, 26) - Me.ucrObjectReceiver.TabIndex = 93 + 'ucrSelectorDescribeOneVar + ' + Me.ucrSelectorDescribeOneVar.bShowHiddenColumns = False + Me.ucrSelectorDescribeOneVar.Location = New System.Drawing.Point(10, 10) + Me.ucrSelectorDescribeOneVar.Margin = New System.Windows.Forms.Padding(0) + Me.ucrSelectorDescribeOneVar.Name = "ucrSelectorDescribeOneVar" + Me.ucrSelectorDescribeOneVar.Size = New System.Drawing.Size(213, 147) + Me.ucrSelectorDescribeOneVar.TabIndex = 92 ' 'lblSelectedVariable ' Me.lblSelectedVariable.AutoSize = True - Me.lblSelectedVariable.Location = New System.Drawing.Point(236, 41) + Me.lblSelectedVariable.Location = New System.Drawing.Point(272, 10) Me.lblSelectedVariable.Name = "lblSelectedVariable" Me.lblSelectedVariable.Size = New System.Drawing.Size(90, 13) Me.lblSelectedVariable.TabIndex = 94 Me.lblSelectedVariable.Tag = "Selected_Variable" Me.lblSelectedVariable.Text = "Selected Variable" ' - 'ucrBase + 'ucrBaseDescribeOneVar + ' + Me.ucrBaseDescribeOneVar.Location = New System.Drawing.Point(10, 228) + Me.ucrBaseDescribeOneVar.Name = "ucrBaseDescribeOneVar" + Me.ucrBaseDescribeOneVar.Size = New System.Drawing.Size(399, 53) + Me.ucrBaseDescribeOneVar.TabIndex = 95 + ' + 'chkSaveResult + ' + Me.chkSaveResult.AutoSize = True + Me.chkSaveResult.Location = New System.Drawing.Point(10, 169) + Me.chkSaveResult.Name = "chkSaveResult" + Me.chkSaveResult.Size = New System.Drawing.Size(87, 17) + Me.chkSaveResult.TabIndex = 96 + Me.chkSaveResult.Tag = "Save_Result" + Me.chkSaveResult.Text = "Save Result " + Me.chkSaveResult.UseVisualStyleBackColor = True ' - Me.ucrBase.Location = New System.Drawing.Point(10, 228) - Me.ucrBase.Name = "ucrBase" - Me.ucrBase.Size = New System.Drawing.Size(399, 53) - Me.ucrBase.TabIndex = 95 + 'lblNewDataFrame + ' + Me.lblNewDataFrame.AutoSize = True + Me.lblNewDataFrame.Location = New System.Drawing.Point(28, 189) + Me.lblNewDataFrame.Name = "lblNewDataFrame" + Me.lblNewDataFrame.Size = New System.Drawing.Size(108, 13) + Me.lblNewDataFrame.TabIndex = 97 + Me.lblNewDataFrame.Tag = "Into_New_Data_Frame" + Me.lblNewDataFrame.Text = "Into New Data Frame" + ' + 'UcrInputTextBox1 + ' + Me.UcrInputTextBox1.IsReadOnly = False + Me.UcrInputTextBox1.Location = New System.Drawing.Point(143, 184) + Me.UcrInputTextBox1.Name = "UcrInputTextBox1" + Me.UcrInputTextBox1.Size = New System.Drawing.Size(95, 21) + Me.UcrInputTextBox1.TabIndex = 98 + ' + 'ucrReceiverDescribeOneVar + ' + Me.ucrReceiverDescribeOneVar.Location = New System.Drawing.Point(260, 23) + Me.ucrReceiverDescribeOneVar.Margin = New System.Windows.Forms.Padding(0) + Me.ucrReceiverDescribeOneVar.Name = "ucrReceiverDescribeOneVar" + Me.ucrReceiverDescribeOneVar.Selector = Nothing + Me.ucrReceiverDescribeOneVar.Size = New System.Drawing.Size(120, 100) + Me.ucrReceiverDescribeOneVar.TabIndex = 99 ' 'dlgDescriptiveStatistics ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(419, 297) - Me.Controls.Add(Me.ucrBase) + Me.Controls.Add(Me.ucrReceiverDescribeOneVar) + Me.Controls.Add(Me.UcrInputTextBox1) + Me.Controls.Add(Me.lblNewDataFrame) + Me.Controls.Add(Me.chkSaveResult) + Me.Controls.Add(Me.ucrBaseDescribeOneVar) Me.Controls.Add(Me.lblSelectedVariable) - Me.Controls.Add(Me.ucrObjectReceiver) - Me.Controls.Add(Me.ucrDataSelector) + Me.Controls.Add(Me.ucrSelectorDescribeOneVar) Me.Controls.Add(Me.cmdStatistics) - Me.Controls.Add(Me.grpgraphics) - Me.Controls.Add(Me.chkGraphics) Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "dlgDescriptiveStatistics" Me.ShowIcon = False - Me.Tag = "Descriptive_Statistics" - Me.Text = "Descriptive Statistics" - Me.grpgraphics.ResumeLayout(False) - Me.grpgraphics.PerformLayout() + Me.Tag = "Describe_One_Variable" + Me.Text = "Describe One Variable" Me.ResumeLayout(False) Me.PerformLayout() - End Sub - Friend WithEvents cmdStatistics As Button - Friend WithEvents grpgraphics As GroupBox - Friend WithEvents chkCumulativeFrequency As CheckBox - Friend WithEvents chkBoxPlot As CheckBox - Friend WithEvents chkStemAndLeaf As CheckBox - Friend WithEvents chkGraphics As CheckBox - Friend WithEvents ucrDataSelector As ucrSelectorAddRemove - Friend WithEvents ucrObjectReceiver As ucrReceiverSingle + End Sub + Friend WithEvents cmdStatistics As Button + Friend WithEvents ucrSelectorDescribeOneVar As ucrSelectorAddRemove Friend WithEvents lblSelectedVariable As Label - Friend WithEvents ucrBase As ucrButtons -End Class + Friend WithEvents ucrBaseDescribeOneVar As ucrButtons + Friend WithEvents chkSaveResult As CheckBox + Friend WithEvents lblNewDataFrame As Label + Friend WithEvents UcrInputTextBox1 As ucrInputTextBox + Friend WithEvents ucrReceiverDescribeOneVar As ucrReceiverMultiple +End Class + diff --git a/instat/dlgDescriptiveStatistics.vb b/instat/dlgDescriptiveStatistics.vb index 3d7673d50a3..5e8958bf9bc 100644 --- a/instat/dlgDescriptiveStatistics.vb +++ b/instat/dlgDescriptiveStatistics.vb @@ -1,44 +1,137 @@ -' Instat-R -' Copyright (C) 2015 -' -' This program is free software: you can redistribute it and/or modify -' it under the terms of the GNU General Public License as published by -' the Free Software Foundation, either version 3 of the License, or -' (at your option) any later version. -' -' This program is distributed in the hope that it will be useful, -' but WITHOUT ANY WARRANTY; without even the implied warranty of -' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -' GNU General Public License for more details. -' -' You should have received a copy of the GNU General Public License k -' along with this program. If not, see . - -Imports instat.Translations -Public Class dlgDescriptiveStatistics - Private Sub dlgDescriptiveStatistics_Load(sender As Object, e As EventArgs) Handles MyBase.Load - ucrObjectReceiver.Selector = ucrDataSelector - ucrObjectReceiver.SetMeAsReceiver() - ucrBase.clsRsyntax.SetFunction("summary") - ucrBase.clsRsyntax.iCallType = 2 - autoTranslate(Me) - grpgraphics.Visible = False - End Sub - - Private Sub chkGraphics_CheckedChanged(sender As Object, e As EventArgs) Handles chkGraphics.CheckedChanged - If chkGraphics.Checked = True Then - grpgraphics.Visible = True - End If - If chkGraphics.Checked = False Then - grpgraphics.Visible = False - End If - End Sub - - Private Sub ucrObjectReceiver_Leave(sender As Object, e As EventArgs) Handles ucrObjectReceiver.Leave - ucrBase.clsRsyntax.AddParameter("object", clsRFunctionParameter:=ucrObjectReceiver.GetVariables()) - End Sub -End Class - - - - +' Instat-R +' Copyright (C) 2015 +' +' This program is free software: you can redistribute it and/or modify +' it under the terms of the GNU General Public License as published by +' the Free Software Foundation, either version 3 of the License, or +' (at your option) any later version. +' +' This program is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU General Public License for more details. +' +' You should have received a copy of the GNU General Public License k +' along with this program. If not, see . + +Imports instat.Translations +Public Class dlgDescriptiveStatistics + Public bFirstLoad As Boolean = True + Public clsRBaseStatsFunction, clsRMissingFunction, clsRMissingSubFunction As New RFunction + Private Sub dlgDescriptiveStatistics_Load(sender As Object, e As EventArgs) Handles MyBase.Load + If bFirstLoad Then + InitialiseDialog() + SetDefaults() + bFirstLoad = False + Else + ReopenDialog() + End If + autoTranslate(Me) + + + + End Sub + + Private Sub InitialiseDialog() + ucrReceiverDescribeOneVar.Selector = ucrSelectorDescribeOneVar + ucrReceiverDescribeOneVar.SetDataType("numeric") + ' ucrBaseDescribeOneVar.clsRsyntax.SetFunction("") + ' ucrBaseDescribeOneVar.clsRsyntax.iCallType = 0 + End Sub + + Private Sub ReopenDialog() + + End Sub + + Private Sub SetDefaults() + ucrReceiverDescribeOneVar.SetMeAsReceiver() + sdgDescribe.SetDefaults() + ucrSelectorDescribeOneVar.Reset() + ucrSelectorDescribeOneVar.Focus() + TestOKEnabled() + End Sub + + Private Sub TestOKEnabled() + If Not ucrReceiverDescribeOneVar.IsEmpty() Then + ucrBaseDescribeOneVar.OKEnabled(True) + Else + ucrBaseDescribeOneVar.OKEnabled(False) + End If + End Sub + + Public Sub ucrReceiverDescribeOneVar_selectionchanged() Handles ucrReceiverDescribeOneVar.SelectionChanged + TestOKEnabled() + End Sub + + Private Sub cmdStatistics_Click(sender As Object, e As EventArgs) Handles cmdStatistics.Click + sdgDescribe.ShowDialog() + End Sub + + Private Sub ucrBaseDescribeOneVar_ClickOk(sender As Object, e As EventArgs) Handles ucrBaseDescribeOneVar.ClickOk + StatsOptions() + End Sub + + Private Sub ucrBaseDescribeOneVar_ClickReset(sender As Object, e As EventArgs) Handles ucrBaseDescribeOneVar.ClickReset + SetDefaults() + End Sub + Public Sub StatsOptions() + If sdgDescribe.chkMean.Checked Then + RBaseStats("mean") + End If + If sdgDescribe.chkStdDev.Checked Then + RBaseStats("sd") + End If + If sdgDescribe.chkMaximum.Checked Then + RBaseStats("max") + End If + If sdgDescribe.chkMinimum.Checked Then + RBaseStats("min") + End If + If sdgDescribe.chkNMissing.Checked Then + RNMissing("is.na") + End If + If sdgDescribe.chkN.Checked Then + RNMissing("!is.na") + End If + If sdgDescribe.chkNTotal.Checked Then + RBaseStats("length") + End If + End Sub + + Public Sub RBaseStats(strStat As String) + If ucrReceiverDescribeOneVar.lstSelectedVariables.Items.Count > 1 Then + clsRBaseStatsFunction.SetRCommand("apply") + clsRBaseStatsFunction.AddParameter("X", clsRFunctionParameter:=ucrReceiverDescribeOneVar.GetVariables()) + clsRBaseStatsFunction.AddParameter("MARGIN", "2") + clsRBaseStatsFunction.AddParameter("FUN", strStat) + clsRBaseStatsFunction.RemoveParameterByName("x") + Else + clsRBaseStatsFunction.SetRCommand(strStat) + clsRBaseStatsFunction.AddParameter("x", clsRFunctionParameter:=ucrReceiverDescribeOneVar.GetVariables()) + clsRBaseStatsFunction.RemoveParameterByName("X") + clsRBaseStatsFunction.RemoveParameterByName("MARGIN") + clsRBaseStatsFunction.RemoveParameterByName("FUN") + End If + frmMain.clsRLink.RunScript(clsRBaseStatsFunction.ToScript(), 2) + End Sub + + Public Sub RNMissing(strMissing As String) + clsRMissingSubFunction.SetRCommand(strMissing) + clsRMissingSubFunction.AddParameter("x", clsRFunctionParameter:=ucrReceiverDescribeOneVar.GetVariables()) + If ucrReceiverDescribeOneVar.lstSelectedVariables.Items.Count > 1 Then + clsRMissingFunction.SetRCommand("apply") + clsRMissingFunction.AddParameter("X", clsRFunctionParameter:=clsRMissingSubFunction) + clsRMissingFunction.AddParameter("MARGIN", "2") + clsRMissingFunction.AddParameter("FUN", "sum") + clsRMissingFunction.RemoveParameterByName("x") + Else + clsRMissingFunction.SetRCommand("sum") + clsRMissingFunction.AddParameter("x", clsRFunctionParameter:=clsRMissingSubFunction) + clsRMissingFunction.RemoveParameterByName("X") + clsRMissingFunction.RemoveParameterByName("MARGIN") + clsRMissingFunction.RemoveParameterByName("FUN") + End If + frmMain.clsRLink.RunScript(clsRMissingFunction.ToScript(), 2) + End Sub + +End Class diff --git a/instat/dlgFromLibrary.vb b/instat/dlgFromLibrary.vb index 35549d114a7..b8a0014e8ba 100644 --- a/instat/dlgFromLibrary.vb +++ b/instat/dlgFromLibrary.vb @@ -77,10 +77,10 @@ Public Class dlgFromLibrary Dim i As Integer Dim lstAvailablePackages As CharacterVector cboPackages.Items.Clear() - lstAvailablePackages = frmMain.clsRLink.clsEngine.Evaluate(strPackages & "<-(.packages())").AsCharacter + lstAvailablePackages = frmMain.clsRLink.RunInternalScriptGetValue(strPackages & "<-(.packages())").AsCharacter For i = 0 To lstAvailablePackages.Length - 1 Try - If frmMain.clsRLink.clsEngine.Evaluate("nrow(data(package = " & Chr(34) & lstAvailablePackages.AsCharacter(i) & Chr(34) & ")$results)").AsInteger(0) > 0 Then + If frmMain.clsRLink.RunInternalScriptGetValue("nrow(data(package = " & Chr(34) & lstAvailablePackages.AsCharacter(i) & Chr(34) & ")$results)").AsInteger(0) > 0 Then cboPackages.Items.Add(lstAvailablePackages.AsCharacter(i)) End If Catch ex As Exception @@ -103,8 +103,7 @@ Public Class dlgFromLibrary Private Sub loadDatasets(strPackage As String) Try Dim dfPackage As DataFrame - frmMain.clsRLink.clsEngine.Evaluate(strLibraryTemp & "<-data.frame(data(package =" & Chr(34) & strPackage & Chr(34) & ")$results[1:nrow(data(package =" & Chr(34) & strPackage & Chr(34) & ")$results),3:4])") - dfPackage = frmMain.clsRLink.clsEngine.GetSymbol(strLibraryTemp).AsDataFrame + dfPackage = frmMain.clsRLink.RunInternalScriptGetValue("data.frame(data(package =" & Chr(34) & strPackage & Chr(34) & ")$results[1:nrow(data(package =" & Chr(34) & strPackage & Chr(34) & ")$results),3:4])").AsDataFrame If dfPackage.RowCount > 1 Then FillListView(dfDataframe:=dfPackage) End If diff --git a/instat/dlgRegularSequence.vb b/instat/dlgRegularSequence.vb index 3a215865129..7663e5d6dc8 100644 --- a/instat/dlgRegularSequence.vb +++ b/instat/dlgRegularSequence.vb @@ -239,7 +239,7 @@ Public Class dlgRegularSequence ucrBase.clsRsyntax.clsBaseFunction.bToBeAssigned = False ucrBase.clsRsyntax.RemoveParameter("length.out") strRCommand = ucrBase.clsRsyntax.clsBaseFunction.ToScript() - vecSequence = frmMain.clsRLink.RunInternalScriptGetValue(strRCommand).AsNumeric + vecSequence = frmMain.clsRLink.RunInternalScriptGetValue(strRCommand, bSilent:=True).AsNumeric iLength = vecSequence.Length If iLength <> ucrSelectDataFrameRegularSequence.iDataFrameLength Then ucrBase.clsRsyntax.SetBaseRFunction(clsRepFunction) @@ -247,7 +247,7 @@ Public Class dlgRegularSequence clsRepFunction.AddParameter("length.out", ucrSelectDataFrameRegularSequence.iDataFrameLength) strRCommand = ucrBase.clsRsyntax.clsBaseFunction.ToScript() bIsAssigned = False - vecSequence = frmMain.clsRLink.RunInternalScriptGetValue(strRCommand).AsNumeric + vecSequence = frmMain.clsRLink.RunInternalScriptGetValue(strRCommand, bSilent:=True).AsNumeric SetAssignTo() If iLength < ucrSelectDataFrameRegularSequence.iDataFrameLength Then txtMessage.Text = "Sequence has been extended by repeating to match the length of the dataframe." diff --git a/instat/dlgReplace.Designer.vb b/instat/dlgReplace.Designer.vb index 86a9e9d8d3b..8b1e2863a57 100644 --- a/instat/dlgReplace.Designer.vb +++ b/instat/dlgReplace.Designer.vb @@ -23,7 +23,10 @@ Partial Class dlgReplace _ Private Sub InitializeComponent() Me.grpOld = New System.Windows.Forms.GroupBox() - Me.chkClosedLowerRange = New System.Windows.Forms.CheckBox() + Me.chkIncludingMaximum = New System.Windows.Forms.CheckBox() + Me.lblMaximum = New System.Windows.Forms.Label() + Me.lblRangeMin = New System.Windows.Forms.Label() + Me.chkIncludeMinimum = New System.Windows.Forms.CheckBox() Me.rdoRange = New System.Windows.Forms.RadioButton() Me.rdoOldMissing = New System.Windows.Forms.RadioButton() Me.rdoOldValue = New System.Windows.Forms.RadioButton() @@ -32,66 +35,95 @@ Partial Class dlgReplace Me.rdoNewValue = New System.Windows.Forms.RadioButton() Me.rdoFromAbove = New System.Windows.Forms.RadioButton() Me.lblSelectedColumns = New System.Windows.Forms.Label() - Me.chkClosedUpperRange = New System.Windows.Forms.CheckBox() Me.ucrInputNewValue = New instat.ucrInputTextBox() Me.ucrInputRangeTo = New instat.ucrInputTextBox() - Me.ucrInputRangeFro = New instat.ucrInputTextBox() + Me.ucrInputRangeFrom = New instat.ucrInputTextBox() Me.ucrInputOldValue = New instat.ucrInputTextBox() Me.ucrReceiverReplace = New instat.ucrReceiverMultiple() Me.ucrSelectorReplace = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrBaseReplace = New instat.ucrButtons() - Me.lblFrom = New System.Windows.Forms.Label() - Me.lblTo = New System.Windows.Forms.Label() Me.grpOld.SuspendLayout() Me.grpNew.SuspendLayout() Me.SuspendLayout() ' 'grpOld ' - Me.grpOld.Controls.Add(Me.lblTo) - Me.grpOld.Controls.Add(Me.lblFrom) - Me.grpOld.Controls.Add(Me.chkClosedLowerRange) + Me.grpOld.Controls.Add(Me.chkIncludingMaximum) + Me.grpOld.Controls.Add(Me.lblMaximum) + Me.grpOld.Controls.Add(Me.lblRangeMin) + Me.grpOld.Controls.Add(Me.chkIncludeMinimum) Me.grpOld.Controls.Add(Me.ucrInputRangeTo) - Me.grpOld.Controls.Add(Me.ucrInputRangeFro) + Me.grpOld.Controls.Add(Me.ucrInputRangeFrom) Me.grpOld.Controls.Add(Me.ucrInputOldValue) Me.grpOld.Controls.Add(Me.rdoRange) Me.grpOld.Controls.Add(Me.rdoOldMissing) Me.grpOld.Controls.Add(Me.rdoOldValue) - Me.grpOld.Location = New System.Drawing.Point(12, 189) + Me.grpOld.Location = New System.Drawing.Point(10, 194) Me.grpOld.Name = "grpOld" - Me.grpOld.Size = New System.Drawing.Size(203, 123) + Me.grpOld.Size = New System.Drawing.Size(229, 143) Me.grpOld.TabIndex = 11 Me.grpOld.TabStop = False Me.grpOld.Tag = "Old" Me.grpOld.Text = "Old" ' - 'chkClosedLowerRange - ' - Me.chkClosedLowerRange.AutoSize = True - Me.chkClosedLowerRange.Location = New System.Drawing.Point(140, 76) - Me.chkClosedLowerRange.Name = "chkClosedLowerRange" - Me.chkClosedLowerRange.Size = New System.Drawing.Size(58, 17) - Me.chkClosedLowerRange.TabIndex = 6 - Me.chkClosedLowerRange.Tag = "Closed" - Me.chkClosedLowerRange.Text = "Closed" - Me.chkClosedLowerRange.UseVisualStyleBackColor = True + 'chkIncludingMaximum + ' + Me.chkIncludingMaximum.AutoSize = True + Me.chkIncludingMaximum.Location = New System.Drawing.Point(154, 109) + Me.chkIncludingMaximum.Name = "chkIncludingMaximum" + Me.chkIncludingMaximum.Size = New System.Drawing.Size(69, 17) + Me.chkIncludingMaximum.TabIndex = 7 + Me.chkIncludingMaximum.Tag = "Including" + Me.chkIncludingMaximum.Text = "Including" + Me.chkIncludingMaximum.UseVisualStyleBackColor = True + ' + 'lblMaximum + ' + Me.lblMaximum.AutoSize = True + Me.lblMaximum.Location = New System.Drawing.Point(22, 108) + Me.lblMaximum.Name = "lblMaximum" + Me.lblMaximum.Size = New System.Drawing.Size(51, 13) + Me.lblMaximum.TabIndex = 8 + Me.lblMaximum.Tag = "Maximum" + Me.lblMaximum.Text = "Maximum" + ' + 'lblRangeMin + ' + Me.lblRangeMin.AutoSize = True + Me.lblRangeMin.Location = New System.Drawing.Point(22, 80) + Me.lblRangeMin.Name = "lblRangeMin" + Me.lblRangeMin.Size = New System.Drawing.Size(48, 13) + Me.lblRangeMin.TabIndex = 7 + Me.lblRangeMin.Tag = "Minimum" + Me.lblRangeMin.Text = "Minimum" + ' + 'chkIncludeMinimum + ' + Me.chkIncludeMinimum.AutoSize = True + Me.chkIncludeMinimum.Location = New System.Drawing.Point(154, 78) + Me.chkIncludeMinimum.Name = "chkIncludeMinimum" + Me.chkIncludeMinimum.Size = New System.Drawing.Size(69, 17) + Me.chkIncludeMinimum.TabIndex = 6 + Me.chkIncludeMinimum.Tag = "Including" + Me.chkIncludeMinimum.Text = "Including" + Me.chkIncludeMinimum.UseVisualStyleBackColor = True ' 'rdoRange ' Me.rdoRange.AutoSize = True - Me.rdoRange.Location = New System.Drawing.Point(6, 56) + Me.rdoRange.Location = New System.Drawing.Point(5, 60) Me.rdoRange.Name = "rdoRange" - Me.rdoRange.Size = New System.Drawing.Size(57, 17) + Me.rdoRange.Size = New System.Drawing.Size(60, 17) Me.rdoRange.TabIndex = 2 Me.rdoRange.TabStop = True Me.rdoRange.Tag = "Range" - Me.rdoRange.Text = "Range" + Me.rdoRange.Text = "Range:" Me.rdoRange.UseVisualStyleBackColor = True ' 'rdoOldMissing ' Me.rdoOldMissing.AutoSize = True - Me.rdoOldMissing.Location = New System.Drawing.Point(7, 37) + Me.rdoOldMissing.Location = New System.Drawing.Point(5, 40) Me.rdoOldMissing.Name = "rdoOldMissing" Me.rdoOldMissing.Size = New System.Drawing.Size(60, 17) Me.rdoOldMissing.TabIndex = 1 @@ -103,13 +135,13 @@ Partial Class dlgReplace 'rdoOldValue ' Me.rdoOldValue.AutoSize = True - Me.rdoOldValue.Location = New System.Drawing.Point(7, 17) + Me.rdoOldValue.Location = New System.Drawing.Point(5, 20) Me.rdoOldValue.Name = "rdoOldValue" - Me.rdoOldValue.Size = New System.Drawing.Size(52, 17) + Me.rdoOldValue.Size = New System.Drawing.Size(55, 17) Me.rdoOldValue.TabIndex = 0 Me.rdoOldValue.TabStop = True Me.rdoOldValue.Tag = "Value" - Me.rdoOldValue.Text = "Value" + Me.rdoOldValue.Text = "Value:" Me.rdoOldValue.UseVisualStyleBackColor = True ' 'grpNew @@ -118,9 +150,9 @@ Partial Class dlgReplace Me.grpNew.Controls.Add(Me.rdoNewMissing) Me.grpNew.Controls.Add(Me.rdoNewValue) Me.grpNew.Controls.Add(Me.rdoFromAbove) - Me.grpNew.Location = New System.Drawing.Point(221, 201) + Me.grpNew.Location = New System.Drawing.Point(247, 194) Me.grpNew.Name = "grpNew" - Me.grpNew.Size = New System.Drawing.Size(174, 94) + Me.grpNew.Size = New System.Drawing.Size(174, 143) Me.grpNew.TabIndex = 12 Me.grpNew.TabStop = False Me.grpNew.Tag = "New" @@ -129,7 +161,7 @@ Partial Class dlgReplace 'rdoNewMissing ' Me.rdoNewMissing.AutoSize = True - Me.rdoNewMissing.Location = New System.Drawing.Point(13, 43) + Me.rdoNewMissing.Location = New System.Drawing.Point(5, 40) Me.rdoNewMissing.Name = "rdoNewMissing" Me.rdoNewMissing.Size = New System.Drawing.Size(60, 17) Me.rdoNewMissing.TabIndex = 5 @@ -141,19 +173,19 @@ Partial Class dlgReplace 'rdoNewValue ' Me.rdoNewValue.AutoSize = True - Me.rdoNewValue.Location = New System.Drawing.Point(13, 20) + Me.rdoNewValue.Location = New System.Drawing.Point(5, 20) Me.rdoNewValue.Name = "rdoNewValue" - Me.rdoNewValue.Size = New System.Drawing.Size(52, 17) + Me.rdoNewValue.Size = New System.Drawing.Size(55, 17) Me.rdoNewValue.TabIndex = 4 Me.rdoNewValue.TabStop = True Me.rdoNewValue.Tag = "Value" - Me.rdoNewValue.Text = "Value" + Me.rdoNewValue.Text = "Value:" Me.rdoNewValue.UseVisualStyleBackColor = True ' 'rdoFromAbove ' Me.rdoFromAbove.AutoSize = True - Me.rdoFromAbove.Location = New System.Drawing.Point(16, 70) + Me.rdoFromAbove.Location = New System.Drawing.Point(5, 60) Me.rdoFromAbove.Name = "rdoFromAbove" Me.rdoFromAbove.Size = New System.Drawing.Size(81, 17) Me.rdoFromAbove.TabIndex = 3 @@ -165,59 +197,48 @@ Partial Class dlgReplace 'lblSelectedColumns ' Me.lblSelectedColumns.AutoSize = True - Me.lblSelectedColumns.Location = New System.Drawing.Point(283, 41) + Me.lblSelectedColumns.Location = New System.Drawing.Point(273, 30) Me.lblSelectedColumns.Name = "lblSelectedColumns" Me.lblSelectedColumns.Size = New System.Drawing.Size(98, 13) Me.lblSelectedColumns.TabIndex = 13 Me.lblSelectedColumns.Tag = "Selected_Column(s)" Me.lblSelectedColumns.Text = "Selected Column(s)" ' - 'chkClosedUpperRange - ' - Me.chkClosedUpperRange.AutoSize = True - Me.chkClosedUpperRange.Location = New System.Drawing.Point(152, 291) - Me.chkClosedUpperRange.Name = "chkClosedUpperRange" - Me.chkClosedUpperRange.Size = New System.Drawing.Size(58, 17) - Me.chkClosedUpperRange.TabIndex = 7 - Me.chkClosedUpperRange.Tag = "Closed" - Me.chkClosedUpperRange.Text = "Closed" - Me.chkClosedUpperRange.UseVisualStyleBackColor = True - ' 'ucrInputNewValue ' Me.ucrInputNewValue.IsReadOnly = False - Me.ucrInputNewValue.Location = New System.Drawing.Point(80, 16) + Me.ucrInputNewValue.Location = New System.Drawing.Point(63, 19) Me.ucrInputNewValue.Name = "ucrInputNewValue" - Me.ucrInputNewValue.Size = New System.Drawing.Size(69, 21) + Me.ucrInputNewValue.Size = New System.Drawing.Size(97, 21) Me.ucrInputNewValue.TabIndex = 6 ' 'ucrInputRangeTo ' Me.ucrInputRangeTo.IsReadOnly = False - Me.ucrInputRangeTo.Location = New System.Drawing.Point(58, 98) + Me.ucrInputRangeTo.Location = New System.Drawing.Point(79, 106) Me.ucrInputRangeTo.Name = "ucrInputRangeTo" Me.ucrInputRangeTo.Size = New System.Drawing.Size(69, 21) Me.ucrInputRangeTo.TabIndex = 5 ' - 'ucrInputRangeFro + 'ucrInputRangeFrom ' - Me.ucrInputRangeFro.IsReadOnly = False - Me.ucrInputRangeFro.Location = New System.Drawing.Point(58, 73) - Me.ucrInputRangeFro.Name = "ucrInputRangeFro" - Me.ucrInputRangeFro.Size = New System.Drawing.Size(69, 21) - Me.ucrInputRangeFro.TabIndex = 4 + Me.ucrInputRangeFrom.IsReadOnly = False + Me.ucrInputRangeFrom.Location = New System.Drawing.Point(79, 76) + Me.ucrInputRangeFrom.Name = "ucrInputRangeFrom" + Me.ucrInputRangeFrom.Size = New System.Drawing.Size(69, 21) + Me.ucrInputRangeFrom.TabIndex = 4 ' 'ucrInputOldValue ' Me.ucrInputOldValue.IsReadOnly = False - Me.ucrInputOldValue.Location = New System.Drawing.Point(73, 14) + Me.ucrInputOldValue.Location = New System.Drawing.Point(58, 19) Me.ucrInputOldValue.Name = "ucrInputOldValue" - Me.ucrInputOldValue.Size = New System.Drawing.Size(51, 21) + Me.ucrInputOldValue.Size = New System.Drawing.Size(95, 21) Me.ucrInputOldValue.TabIndex = 3 ' 'ucrReceiverReplace ' - Me.ucrReceiverReplace.Location = New System.Drawing.Point(275, 61) + Me.ucrReceiverReplace.Location = New System.Drawing.Point(276, 52) Me.ucrReceiverReplace.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverReplace.Name = "ucrReceiverReplace" Me.ucrReceiverReplace.Selector = Nothing @@ -227,7 +248,7 @@ Partial Class dlgReplace 'ucrSelectorReplace ' Me.ucrSelectorReplace.bShowHiddenColumns = False - Me.ucrSelectorReplace.Location = New System.Drawing.Point(12, 6) + Me.ucrSelectorReplace.Location = New System.Drawing.Point(10, 10) Me.ucrSelectorReplace.Margin = New System.Windows.Forms.Padding(0) Me.ucrSelectorReplace.Name = "ucrSelectorReplace" Me.ucrSelectorReplace.Size = New System.Drawing.Size(210, 180) @@ -235,37 +256,16 @@ Partial Class dlgReplace ' 'ucrBaseReplace ' - Me.ucrBaseReplace.Location = New System.Drawing.Point(4, 318) + Me.ucrBaseReplace.Location = New System.Drawing.Point(10, 343) Me.ucrBaseReplace.Name = "ucrBaseReplace" Me.ucrBaseReplace.Size = New System.Drawing.Size(410, 52) Me.ucrBaseReplace.TabIndex = 8 ' - 'lblFrom - ' - Me.lblFrom.AutoSize = True - Me.lblFrom.Location = New System.Drawing.Point(21, 78) - Me.lblFrom.Name = "lblFrom" - Me.lblFrom.Size = New System.Drawing.Size(30, 13) - Me.lblFrom.TabIndex = 7 - Me.lblFrom.Tag = "From" - Me.lblFrom.Text = "From" - ' - 'lblTo - ' - Me.lblTo.AutoSize = True - Me.lblTo.Location = New System.Drawing.Point(28, 101) - Me.lblTo.Name = "lblTo" - Me.lblTo.Size = New System.Drawing.Size(20, 13) - Me.lblTo.TabIndex = 8 - Me.lblTo.Tag = "To" - Me.lblTo.Text = "To" - ' 'dlgReplace ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(419, 376) - Me.Controls.Add(Me.chkClosedUpperRange) + Me.ClientSize = New System.Drawing.Size(452, 397) Me.Controls.Add(Me.lblSelectedColumns) Me.Controls.Add(Me.grpNew) Me.Controls.Add(Me.grpOld) @@ -291,7 +291,7 @@ Partial Class dlgReplace Friend WithEvents grpOld As GroupBox Friend WithEvents grpNew As GroupBox Friend WithEvents ucrInputRangeTo As ucrInputTextBox - Friend WithEvents ucrInputRangeFro As ucrInputTextBox + Friend WithEvents ucrInputRangeFrom As ucrInputTextBox Friend WithEvents ucrInputOldValue As ucrInputTextBox Friend WithEvents rdoRange As RadioButton Friend WithEvents rdoOldMissing As RadioButton @@ -301,8 +301,8 @@ Partial Class dlgReplace Friend WithEvents rdoNewValue As RadioButton Friend WithEvents rdoFromAbove As RadioButton Friend WithEvents lblSelectedColumns As Label - Friend WithEvents chkClosedLowerRange As CheckBox - Friend WithEvents chkClosedUpperRange As CheckBox - Friend WithEvents lblTo As Label - Friend WithEvents lblFrom As Label + Friend WithEvents chkIncludeMinimum As CheckBox + Friend WithEvents chkIncludingMaximum As CheckBox + Friend WithEvents lblMaximum As Label + Friend WithEvents lblRangeMin As Label End Class diff --git a/instat/dlgReplace.vb b/instat/dlgReplace.vb index 851a582a2e2..fd3ff3d3c44 100644 --- a/instat/dlgReplace.vb +++ b/instat/dlgReplace.vb @@ -14,9 +14,13 @@ ' You should have received a copy of the GNU General Public License k ' along with this program. If not, see . Imports instat.Translations +Imports RDotNet + Public Class dlgReplace Public bFirstLoad As Boolean = True Dim strVarType As String + Dim clsGetDataType As New RFunction + Private Sub dlgReplace_Load(sender As Object, e As EventArgs) Handles MyBase.Load If bFirstLoad Then InitialiseDialog() @@ -31,9 +35,12 @@ Public Class dlgReplace Private Sub InitialiseDialog() ucrBaseReplace.clsRsyntax.SetFunction(frmMain.clsRLink.strInstatDataObject & "$replace_value_in_data") - 'ucrBasePCA.clsRsyntax.iCallType = 0 ucrReceiverReplace.Selector = ucrSelectorReplace + ucrReceiverReplace.SetMeAsReceiver() ucrBaseReplace.iHelpTopicID = 47 + clsGetDataType.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_variables_metadata") + clsGetDataType.AddParameter("property", "data_type_label") + rdoFromAbove.Enabled = False End Sub Private Sub ReopenDialog() @@ -42,29 +49,26 @@ Public Class dlgReplace Private Sub SetDefaults() ucrSelectorReplace.Reset() - ucrReceiverReplace.SetMeAsReceiver() ucrSelectorReplace.Focus() rdoOldValue.Checked = True rdoNewValue.Checked = True - ucrInputOldValue.txtInput.Text = "" - ucrInputNewValue.txtInput.Text = "" - chkClosedLowerRange.Checked = True - chkClosedUpperRange.Checked = True - chkClosedLowerRange.Enabled = False - chkClosedUpperRange.Enabled = False - ucrInputRangeFro.txtInput.Text = "" - ucrInputRangeTo.txtInput.Text = "" - rdoRange.Enabled = False - lblFrom.Enabled = False - lblTo.Enabled = False - ucrInputRangeFro.Enabled = False - ucrInputRangeTo.Enabled = False + ucrInputOldValue.SetName("") + ucrInputNewValue.SetName("") + chkIncludeMinimum.Checked = True + chkIncludingMaximum.Checked = True + ucrInputRangeFrom.SetName("") + ucrInputRangeTo.SetName("") + RangeOption() TestOKEnabled() End Sub Private Sub TestOKEnabled() If (Not ucrReceiverReplace.IsEmpty()) Then - ucrBaseReplace.OKEnabled(True) + If (rdoOldValue.Checked AndAlso ucrInputOldValue.IsEmpty()) OrElse (rdoRange.Checked AndAlso ucrInputRangeFrom.IsEmpty() AndAlso ucrInputRangeTo.IsEmpty()) OrElse (rdoNewValue.Checked AndAlso ucrInputNewValue.IsEmpty()) Then + ucrBaseReplace.OKEnabled(False) + Else + ucrBaseReplace.OKEnabled(True) + End If Else ucrBaseReplace.OKEnabled(False) End If @@ -72,14 +76,16 @@ Public Class dlgReplace Private Sub CheckType() If (Not ucrReceiverReplace.IsEmpty() And ucrReceiverReplace.lstSelectedVariables.Items.Count = 1) Then - strVarType = frmMain.clsRLink.GetDataType(ucrSelectorReplace.ucrAvailableDataFrames.cboAvailableDataFrames.Text, ucrReceiverReplace.GetVariableNames(bWithQuotes:=False)) - If (strVarType = "numeric" Or strVarType = "integer" Or strVarType = "positive integer") Then + clsGetDataType.AddParameter("data_name", Chr(34) & ucrSelectorReplace.ucrAvailableDataFrames.cboAvailableDataFrames.Text & Chr(34)) + clsGetDataType.AddParameter("column", ucrReceiverReplace.GetVariableNames()) + strVarType = frmMain.clsRLink.RunInternalScriptGetValue(clsGetDataType.ToScript()).AsCharacter(0) + If (strVarType = "numeric" OrElse strVarType = "integer") Then ucrReceiverReplace.SetDataType("numeric") End If If (strVarType = "character") Then ucrReceiverReplace.SetDataType("character") End If - If (strVarType = "factor" Or strVarType = "two level factor" Or strVarType = "multilevel factor") Then + If (strVarType = "factor") Then ucrReceiverReplace.SetDataType("factor") End If If (strVarType = "logical") Then @@ -88,7 +94,8 @@ Public Class dlgReplace If (strVarType = "Date") Then ucrReceiverReplace.SetDataType("Date") End If - Else + ElseIf ucrReceiverReplace.IsEmpty() Then + strVarType = "" ucrReceiverReplace.RemoveIncludedMetadataProperty(strProperty:="class") End If End Sub @@ -112,117 +119,139 @@ Public Class dlgReplace End Sub Private Sub InputOldValue() - If (strVarType = "numeric" Or strVarType = "integer" Or strVarType = "positive integer") Then - ucrBaseReplace.clsRsyntax.AddParameter("old_value", ucrInputOldValue.GetText) - End If - If (strVarType = "character") Then - ucrBaseReplace.clsRsyntax.AddParameter("old_value", Chr(34) & ucrInputOldValue.GetText & Chr(34)) - End If - If (strVarType = "factor" Or strVarType = "two level factor" Or strVarType = "multilevel factor") Then - ucrBaseReplace.clsRsyntax.AddParameter("old_value", Chr(34) & ucrInputOldValue.GetText & Chr(34)) + If ucrInputOldValue.IsEmpty() Then + ucrBaseReplace.clsRsyntax.RemoveParameter("old_value") + Else + If (strVarType = "numeric" OrElse strVarType = "integer") Then + ucrBaseReplace.clsRsyntax.AddParameter("old_value", ucrInputOldValue.GetText) + Else + ucrBaseReplace.clsRsyntax.AddParameter("old_value", Chr(34) & ucrInputOldValue.GetText() & Chr(34)) + End If End If - 'If (strVarType = "logical") Then - - 'End If - 'If (strVarType = "Date") Then - - 'End If End Sub Private Sub InputNewValue() - If (strVarType = "numeric" Or strVarType = "integer" Or strVarType = "positive integer") Then - ucrBaseReplace.clsRsyntax.AddParameter("new_value", ucrInputNewValue.GetText) - End If - If (strVarType = "character") Then - ucrBaseReplace.clsRsyntax.AddParameter("new_value", Chr(34) & ucrInputNewValue.GetText & Chr(34)) - End If - If (strVarType = "character" or strVarType = "factor" Or strVarType = "two level factor" Or strVarType = "multilevel factor") Then - ucrBaseReplace.clsRsyntax.AddParameter("new_value", Chr(34) & ucrInputNewValue.GetText & Chr(34)) + If ucrInputNewValue.IsEmpty() Then + ucrBaseReplace.clsRsyntax.RemoveParameter("new_value") + Else + If (strVarType = "numeric" OrElse strVarType = "integer") Then + ucrBaseReplace.clsRsyntax.AddParameter("new_value", ucrInputNewValue.GetText) + Else + ucrBaseReplace.clsRsyntax.AddParameter("new_value", Chr(34) & ucrInputNewValue.GetText & Chr(34)) + End If End If - 'If (strVarType = "logical") Then - - 'End If - 'If (strVarType = "Date") Then - - 'End If End Sub Private Sub rdoOldValue_CheckedChanged(sender As Object, e As EventArgs) Handles rdoOldValue.CheckedChanged If rdoOldValue.Checked Then + ucrInputOldValue.Visible = True InputOldValue() Else ucrBaseReplace.clsRsyntax.RemoveParameter("old_value") - ucrInputOldValue.txtInput.Text = "" + ucrInputOldValue.Visible = False End If + TestOKEnabled() End Sub Private Sub rdoOldMissing_CheckedChanged(sender As Object, e As EventArgs) Handles rdoOldMissing.CheckedChanged If rdoOldMissing.Checked Then - If (strVarType = "numeric" Or strVarType = "integer" Or strVarType = "positive integer") Then - ucrBaseReplace.clsRsyntax.AddParameter("old_value", "NA") - End If - If (strVarType = "character" Or strVarType = "factor" Or strVarType = "two level factor" Or strVarType = "multilevel factor") Then - ucrBaseReplace.clsRsyntax.AddParameter("old_value", Chr(34) & "" & Chr(34)) - End If - 'If (strVarType = "logical") Then - - 'End If - 'If (strVarType = "Date") Then - - 'End If + ucrBaseReplace.clsRsyntax.AddParameter("old_value", "NA") Else ucrBaseReplace.clsRsyntax.RemoveParameter("old_value") End If + TestOKEnabled() End Sub Private Sub rdoNewValue_CheckedChanged(sender As Object, e As EventArgs) Handles rdoNewValue.CheckedChanged If rdoNewValue.Checked Then + ucrInputNewValue.Visible = True InputNewValue() Else + ucrInputNewValue.Visible = False ucrBaseReplace.clsRsyntax.RemoveParameter("new_value") - ucrInputNewValue.txtInput.Text = "" End If + TestOKEnabled() End Sub + Private Sub rdoRange_CheckedChanged(sender As Object, e As EventArgs) Handles rdoRange.CheckedChanged + RangeOption() + End Sub + + Private Sub RangeOption() If rdoRange.Checked Then - ucrBaseReplace.clsRsyntax.AddParameter("start_value", ucrInputRangeFro.GetText) - ucrBaseReplace.clsRsyntax.AddParameter("end_value", ucrInputRangeTo.GetText) - chkClosedLowerRange.Enabled = True - chkClosedUpperRange.Enabled = True + chkIncludeMinimum.Visible = True + chkIncludingMaximum.Visible = True + ucrInputRangeFrom.Visible = True + ucrInputRangeTo.Visible = True + lblMaximum.Visible = True + lblRangeMin.Visible = True + If ucrInputRangeFrom.IsEmpty() Then + ucrBaseReplace.clsRsyntax.RemoveParameter("start_value") + Else + ucrBaseReplace.clsRsyntax.AddParameter("start_value", ucrInputRangeFrom.GetText) + End If + If ucrInputRangeTo.IsEmpty() Then + ucrBaseReplace.clsRsyntax.RemoveParameter("end_value") + Else + ucrBaseReplace.clsRsyntax.AddParameter("end_value", ucrInputRangeTo.GetText) + End If Else ucrBaseReplace.clsRsyntax.RemoveParameter("start_value") ucrBaseReplace.clsRsyntax.RemoveParameter("end_value") - ucrInputRangeFro.txtInput.Text = "" - ucrInputRangeTo.txtInput.Text = "" - chkClosedLowerRange.Checked = True - chkClosedUpperRange.Checked = True - chkClosedLowerRange.Enabled = False - chkClosedUpperRange.Enabled = False + chkIncludeMinimum.Visible = False + chkIncludingMaximum.Visible = False + ucrInputRangeFrom.Visible = False + ucrInputRangeTo.Visible = False + lblMaximum.Visible = False + lblRangeMin.Visible = False End If + ClosedRangeParameters() + RangeToParameter() + RangeFromParameter() + TestOKEnabled() End Sub - Private Sub ucrInputOldValue_NameChanged() Handles ucrInputOldValue.NameChanged If rdoOldValue.Checked Then InputOldValue() Else ucrBaseReplace.clsRsyntax.RemoveParameter("old_value") End If - 'TestOKEnabled() + TestOKEnabled() End Sub - Private Sub ucrInputRangeFro_NameChanged() Handles ucrInputRangeFro.NameChanged + Private Sub ucrInputRangeFrom_NameChanged() Handles ucrInputRangeFrom.NameChanged + RangeFromParameter() + TestOKEnabled() + End Sub + + Private Sub RangeFromParameter() If rdoRange.Checked Then - ucrBaseReplace.clsRsyntax.AddParameter("start_value", ucrInputRangeFro.GetText) + If ucrInputRangeFrom.IsEmpty() Then + ucrBaseReplace.clsRsyntax.RemoveParameter("start_value") + Else + ucrBaseReplace.clsRsyntax.AddParameter("start_value", ucrInputRangeFrom.GetText) + End If + Else + ucrBaseReplace.clsRsyntax.RemoveParameter("start_value") End If - 'TestOKEnabled() End Sub Private Sub ucrInputRangeTo_NameChanged() Handles ucrInputRangeTo.NameChanged + RangeToParameter() + TestOKEnabled() + End Sub + + Private Sub RangeToParameter() If rdoRange.Checked Then - ucrBaseReplace.clsRsyntax.AddParameter("end_value", ucrInputRangeTo.GetText) + If ucrInputRangeTo.IsEmpty() Then + ucrBaseReplace.clsRsyntax.RemoveParameter("end_value") + Else + ucrBaseReplace.clsRsyntax.AddParameter("end_value", ucrInputRangeTo.GetText) + End If + Else + ucrBaseReplace.clsRsyntax.RemoveParameter("end_value") End If - 'TestOKEnabled() End Sub Private Sub ucrInputNewValue_NameChanged() Handles ucrInputNewValue.NameChanged @@ -231,56 +260,63 @@ Public Class dlgReplace Else ucrBaseReplace.clsRsyntax.RemoveParameter("new_value") End If - 'TestOKEnabled() + TestOKEnabled() End Sub - Private Sub chkClosedLowerRange_CheckedChanged(sender As Object, e As EventArgs) Handles chkClosedLowerRange.CheckedChanged - If chkClosedLowerRange.Checked Then - ucrBaseReplace.clsRsyntax.RemoveParameter("closed_start_value") - Else - ucrBaseReplace.clsRsyntax.AddParameter("closed_start_value", "FALSE") - End If + Private Sub chkClosedLowerRange_CheckedChanged(sender As Object, e As EventArgs) Handles chkIncludeMinimum.CheckedChanged + ClosedRangeParameters() + TestOKEnabled() End Sub - Private Sub chkClosedUpperRange_CheckedChanged(sender As Object, e As EventArgs) Handles chkClosedUpperRange.CheckedChanged - If chkClosedUpperRange.Checked Then - ucrBaseReplace.clsRsyntax.RemoveParameter("closed_end_value") + Private Sub chkClosedUpperRange_CheckedChanged(sender As Object, e As EventArgs) Handles chkIncludingMaximum.CheckedChanged + ClosedRangeParameters() + TestOKEnabled() + End Sub + + Private Sub ClosedRangeParameters() + If rdoRange.Checked Then + If chkIncludingMaximum.Checked Then + If frmMain.clsInstatOptions.bIncludeRDefaultParameters Then + ucrBaseReplace.clsRsyntax.AddParameter("closed_end_value", "TRUE") + Else + ucrBaseReplace.clsRsyntax.RemoveParameter("closed_end_value") + End If + Else + ucrBaseReplace.clsRsyntax.AddParameter("closed_end_value", "FALSE") + End If + + If chkIncludeMinimum.Checked Then + If frmMain.clsInstatOptions.bIncludeRDefaultParameters Then + ucrBaseReplace.clsRsyntax.AddParameter("closed_start_value", "TRUE") + Else + ucrBaseReplace.clsRsyntax.RemoveParameter("closed_start_value") + End If + Else + ucrBaseReplace.clsRsyntax.AddParameter("closed_start_value", "FALSE") + End If Else - ucrBaseReplace.clsRsyntax.AddParameter("closed_end_value", "FALSE") + ucrBaseReplace.clsRsyntax.RemoveParameter("closed_start_value") + ucrBaseReplace.clsRsyntax.RemoveParameter("closed_end_value") End If End Sub Private Sub rdoNewMissing_CheckedChanged(sender As Object, e As EventArgs) Handles rdoNewMissing.CheckedChanged If rdoNewMissing.Checked Then - If (strVarType = "numeric" Or strVarType = "integer" Or strVarType = "positive integer") Then - ucrBaseReplace.clsRsyntax.AddParameter("new_value", "NA") - End If - If (strVarType = "character" Or strVarType = "factor" Or strVarType = "two level factor" Or strVarType = "multilevel factor") Then - ucrBaseReplace.clsRsyntax.AddParameter("new_value", Chr(34) & "" & Chr(34)) - End If - 'If (strVarType = "logical") Then - - 'End If - 'If (strVarType = "Date") Then - - 'End If + ucrBaseReplace.clsRsyntax.AddParameter("new_value", "NA") Else - ucrBaseReplace.clsRsyntax.RemoveParameter("new_value") + ucrBaseReplace.clsRsyntax.RemoveParameter("new_value") End If + TestOKEnabled() End Sub + Private Sub RangeEnable() - If ((Not ucrReceiverReplace.IsEmpty()) And (strVarType = "numeric" Or strVarType = "integer" Or strVarType = "positive integer")) Then + If strVarType = "" OrElse strVarType = "numeric" OrElse strVarType = "integer" Then rdoRange.Enabled = True - lblFrom.Enabled = True - lblTo.Enabled = True - ucrInputRangeFro.Enabled = True - ucrInputRangeTo.Enabled = True Else rdoRange.Enabled = False - lblFrom.Enabled = False - lblTo.Enabled = False - ucrInputRangeFro.Enabled = False - ucrInputRangeTo.Enabled = False + If rdoRange.Checked Then + rdoOldValue.Checked = True + End If End If End Sub End Class \ No newline at end of file diff --git a/instat/frmEditor.vb b/instat/frmEditor.vb index a617bcdcb53..1cbcf124c3f 100644 --- a/instat/frmEditor.vb +++ b/instat/frmEditor.vb @@ -101,7 +101,7 @@ Public Class frmEditor End Sub Private Sub mnuDeleteCol_Click(sender As Object, e As EventArgs) Handles mnuDeleteCol.Click - Dim deleteCol = MsgBox("Are you sure you want to delete this column?", MessageBoxButtons.YesNo, "Delete Column") + Dim deleteCol = MsgBox("Are you sure you want to delete these column(s)?" & vbNewLine & "This action cannot be undone.", MessageBoxButtons.YesNo, "Delete Column") If deleteCol = DialogResult.Yes Then clsDeleteColumns.AddParameter("cols", SelectedColumns()) frmMain.clsRLink.RunScript(clsDeleteColumns.ToScript(), strComment:="Right click menu: Delete Column(s)") @@ -227,9 +227,12 @@ Public Class frmEditor frmMain.clsRLink.RunScript(clsInsertRows.ToScript(), strComment:="Right Click menu: Insert row(s) Before") End Sub - Private Sub mnuDeleteRows_Click(sender As Object, e As EventArgs) Handles mnuDeleteRows.Click - clsDeleteRows.AddParameter("row_names", SelectedRows()) - frmMain.clsRLink.RunScript(clsDeleteRows.ToScript(), strComment:="Right Click menu: Delete row(s)") + Private Sub mnuDeleteRows_Click(sender As Object, e As EventArgs) Handles mnuDeleteRows.Click + Dim Delete = MsgBox("Are you sure you want to delete these row(s)?" & vbNewLine & "This action cannot be undone.", MessageBoxButtons.YesNo, "Delete Row(s)") + If Delete = DialogResult.Yes Then + clsDeleteRows.AddParameter("row_names", SelectedRows()) + frmMain.clsRLink.RunScript(clsDeleteRows.ToScript(), strComment:="Right Click menu: Delete row(s)") + End If End Sub 'Private Sub resetToDefaultHeightToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles resetToDefaultHeightToolStripMenuItem.Click @@ -278,12 +281,12 @@ Public Class frmEditor End Sub Private Sub deleteSheet_Click(sender As Object, e As EventArgs) Handles deleteSheet.Click - Dim strSctipt As String - Dim Delete = MsgBox("Are you sure you want to delete this dataframe?", MessageBoxButtons.YesNo, "Delete Sheet") + Dim strScript As String + Dim Delete = MsgBox("Are you sure you want to delete this dataframe?" & vbNewLine & "This action cannot be undone.", MessageBoxButtons.YesNo, "Delete Sheet") If grdData.Worksheets.Count > 0 Then If Delete = DialogResult.Yes Then - strSctipt = frmMain.clsRLink.strInstatDataObject & "$delete_dataframe(data_name =" & Chr(34) & grdData.CurrentWorksheet.Name & Chr(34) & ")" - frmMain.clsRLink.RunScript(strSctipt) + strScript = frmMain.clsRLink.strInstatDataObject & "$delete_dataframe(data_name =" & Chr(34) & grdData.CurrentWorksheet.Name & Chr(34) & ")" + frmMain.clsRLink.RunScript(strScript) End If End If End Sub @@ -575,4 +578,18 @@ Public Class frmEditor Private Sub UnfreezeToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles UnfreezeToolStripMenuItem.Click frmMain.clsRLink.RunScript(clsUnfreezeColumns.ToScript(), strComment:="Right click menu: Freeze columns") End Sub + + Private Sub grdCurrSheet_BeforeCut(sender As Object, e As BeforeRangeOperationEventArgs) Handles grdCurrSheet.BeforeCut + e.IsCancelled = True + End Sub + + Private Sub grdCurrSheet_BeforePaste(sender As Object, e As BeforeRangeOperationEventArgs) Handles grdCurrSheet.BeforePaste + e.IsCancelled = True + End Sub + + ' Not currently working. Bug with reogrid reported here: + ' https://reogrid.net/forum/viewtopic.php?id=350 + Private Sub grdCurrSheet_BeforeRangeMove(sender As Object, e As BeforeCopyOrMoveRangeEventArgs) Handles grdCurrSheet.BeforeRangeMove + e.IsCancelled = True + End Sub End Class \ No newline at end of file diff --git a/instat/frmMain.Designer.vb b/instat/frmMain.Designer.vb index 005918a4604..37b8835bd9e 100644 --- a/instat/frmMain.Designer.vb +++ b/instat/frmMain.Designer.vb @@ -388,9 +388,8 @@ Partial Class frmMain ' 'mnuDescribeTwoVariablesSummarise ' - Me.mnuDescribeTwoVariablesSummarise.Enabled = False Me.mnuDescribeTwoVariablesSummarise.Name = "mnuDescribeTwoVariablesSummarise" - Me.mnuDescribeTwoVariablesSummarise.Size = New System.Drawing.Size(142, 22) + Me.mnuDescribeTwoVariablesSummarise.Size = New System.Drawing.Size(152, 22) Me.mnuDescribeTwoVariablesSummarise.Tag = "Summarise..." Me.mnuDescribeTwoVariablesSummarise.Text = "Summarise..." ' @@ -398,7 +397,7 @@ Partial Class frmMain ' Me.mnuDescribeTwoVariablesTabulate.Enabled = False Me.mnuDescribeTwoVariablesTabulate.Name = "mnuDescribeTwoVariablesTabulate" - Me.mnuDescribeTwoVariablesTabulate.Size = New System.Drawing.Size(142, 22) + Me.mnuDescribeTwoVariablesTabulate.Size = New System.Drawing.Size(152, 22) Me.mnuDescribeTwoVariablesTabulate.Tag = "Tabulate..." Me.mnuDescribeTwoVariablesTabulate.Text = "Tabulate..." ' @@ -406,7 +405,7 @@ Partial Class frmMain ' Me.mnuDescribeTwoVariablesGraph.Enabled = False Me.mnuDescribeTwoVariablesGraph.Name = "mnuDescribeTwoVariablesGraph" - Me.mnuDescribeTwoVariablesGraph.Size = New System.Drawing.Size(142, 22) + Me.mnuDescribeTwoVariablesGraph.Size = New System.Drawing.Size(152, 22) Me.mnuDescribeTwoVariablesGraph.Tag = "Graph..." Me.mnuDescribeTwoVariablesGraph.Text = "Graph..." ' @@ -414,7 +413,7 @@ Partial Class frmMain ' Me.mnuDescribeTwoVariablesCorrelate.Enabled = False Me.mnuDescribeTwoVariablesCorrelate.Name = "mnuDescribeTwoVariablesCorrelate" - Me.mnuDescribeTwoVariablesCorrelate.Size = New System.Drawing.Size(142, 22) + Me.mnuDescribeTwoVariablesCorrelate.Size = New System.Drawing.Size(152, 22) Me.mnuDescribeTwoVariablesCorrelate.Tag = "Correlate..." Me.mnuDescribeTwoVariablesCorrelate.Text = "Correlate..." ' @@ -877,28 +876,28 @@ Partial Class frmMain 'mnuModelOtherTwoVariablesTwoSamples ' Me.mnuModelOtherTwoVariablesTwoSamples.Name = "mnuModelOtherTwoVariablesTwoSamples" - Me.mnuModelOtherTwoVariablesTwoSamples.Size = New System.Drawing.Size(267, 22) + Me.mnuModelOtherTwoVariablesTwoSamples.Size = New System.Drawing.Size(266, 22) Me.mnuModelOtherTwoVariablesTwoSamples.Tag = "Two_Samples..." Me.mnuModelOtherTwoVariablesTwoSamples.Text = "Two Samples..." ' 'mnuModelOtherTwoVariablesSummaryData ' Me.mnuModelOtherTwoVariablesSummaryData.Name = "mnuModelOtherTwoVariablesSummaryData" - Me.mnuModelOtherTwoVariablesSummaryData.Size = New System.Drawing.Size(267, 22) + Me.mnuModelOtherTwoVariablesSummaryData.Size = New System.Drawing.Size(266, 22) Me.mnuModelOtherTwoVariablesSummaryData.Tag = "Summary_Data" Me.mnuModelOtherTwoVariablesSummaryData.Text = "Summary Data..." ' 'mnuModelOtherTwoVariablesSimpleRegression ' Me.mnuModelOtherTwoVariablesSimpleRegression.Name = "mnuModelOtherTwoVariablesSimpleRegression" - Me.mnuModelOtherTwoVariablesSimpleRegression.Size = New System.Drawing.Size(267, 22) + Me.mnuModelOtherTwoVariablesSimpleRegression.Size = New System.Drawing.Size(266, 22) Me.mnuModelOtherTwoVariablesSimpleRegression.Tag = "Simple_Regression" Me.mnuModelOtherTwoVariablesSimpleRegression.Text = "Simple Regression..." ' 'mnuModelOtherTwoVariablesOneWayANOVA ' Me.mnuModelOtherTwoVariablesOneWayANOVA.Name = "mnuModelOtherTwoVariablesOneWayANOVA" - Me.mnuModelOtherTwoVariablesOneWayANOVA.Size = New System.Drawing.Size(267, 22) + Me.mnuModelOtherTwoVariablesOneWayANOVA.Size = New System.Drawing.Size(266, 22) Me.mnuModelOtherTwoVariablesOneWayANOVA.Tag = "One_Way_ANOVA" Me.mnuModelOtherTwoVariablesOneWayANOVA.Text = "One Way ANOVA..." ' @@ -906,14 +905,14 @@ Partial Class frmMain ' Me.mnuModelOtherTwoVariablesNonParametricTwoSamples.Enabled = False Me.mnuModelOtherTwoVariablesNonParametricTwoSamples.Name = "mnuModelOtherTwoVariablesNonParametricTwoSamples" - Me.mnuModelOtherTwoVariablesNonParametricTwoSamples.Size = New System.Drawing.Size(267, 22) + Me.mnuModelOtherTwoVariablesNonParametricTwoSamples.Size = New System.Drawing.Size(266, 22) Me.mnuModelOtherTwoVariablesNonParametricTwoSamples.Tag = "Non_Parameteric_Two_Samples" Me.mnuModelOtherTwoVariablesNonParametricTwoSamples.Text = "Non Parametric Two Samples..." ' 'mnuModelOtherTwoVariablesNonParametricOneWayANOVA ' Me.mnuModelOtherTwoVariablesNonParametricOneWayANOVA.Name = "mnuModelOtherTwoVariablesNonParametricOneWayANOVA" - Me.mnuModelOtherTwoVariablesNonParametricOneWayANOVA.Size = New System.Drawing.Size(267, 22) + Me.mnuModelOtherTwoVariablesNonParametricOneWayANOVA.Size = New System.Drawing.Size(266, 22) Me.mnuModelOtherTwoVariablesNonParametricOneWayANOVA.Tag = "Non_Parameteric_One_Way_ANOVA..." Me.mnuModelOtherTwoVariablesNonParametricOneWayANOVA.Text = "Non Parameteric One Way ANOVA..." ' @@ -929,21 +928,21 @@ Partial Class frmMain ' Me.mnuModelOtherThreeVariablesSimpleWithGroups.Enabled = False Me.mnuModelOtherThreeVariablesSimpleWithGroups.Name = "mnuModelOtherThreeVariablesSimpleWithGroups" - Me.mnuModelOtherThreeVariablesSimpleWithGroups.Size = New System.Drawing.Size(262, 22) + Me.mnuModelOtherThreeVariablesSimpleWithGroups.Size = New System.Drawing.Size(260, 22) Me.mnuModelOtherThreeVariablesSimpleWithGroups.Tag = "Simple_with_groups" Me.mnuModelOtherThreeVariablesSimpleWithGroups.Text = "Simple With Groups..." ' 'mnuModelOtherThreeVariablesNonParametricTwoWayANOVA ' Me.mnuModelOtherThreeVariablesNonParametricTwoWayANOVA.Name = "mnuModelOtherThreeVariablesNonParametricTwoWayANOVA" - Me.mnuModelOtherThreeVariablesNonParametricTwoWayANOVA.Size = New System.Drawing.Size(262, 22) + Me.mnuModelOtherThreeVariablesNonParametricTwoWayANOVA.Size = New System.Drawing.Size(260, 22) Me.mnuModelOtherThreeVariablesNonParametricTwoWayANOVA.Tag = "Non_Parametric_Two_Way_ANOVA..." Me.mnuModelOtherThreeVariablesNonParametricTwoWayANOVA.Text = "Non Parametric Two Way ANOVA..." ' 'mnuModelOtherThreeVariablesChisquareTest ' Me.mnuModelOtherThreeVariablesChisquareTest.Name = "mnuModelOtherThreeVariablesChisquareTest" - Me.mnuModelOtherThreeVariablesChisquareTest.Size = New System.Drawing.Size(262, 22) + Me.mnuModelOtherThreeVariablesChisquareTest.Size = New System.Drawing.Size(260, 22) Me.mnuModelOtherThreeVariablesChisquareTest.Tag = "Chi-square_Test" Me.mnuModelOtherThreeVariablesChisquareTest.Text = "Chi-square Test..." ' @@ -958,21 +957,21 @@ Partial Class frmMain 'mnuModelOtherGeneralANOVAGeneral ' Me.mnuModelOtherGeneralANOVAGeneral.Name = "mnuModelOtherGeneralANOVAGeneral" - Me.mnuModelOtherGeneralANOVAGeneral.Size = New System.Drawing.Size(167, 22) + Me.mnuModelOtherGeneralANOVAGeneral.Size = New System.Drawing.Size(166, 22) Me.mnuModelOtherGeneralANOVAGeneral.Tag = "ANOVA_General..." Me.mnuModelOtherGeneralANOVAGeneral.Text = "ANOVA General..." ' 'mnuModelOtherGeneralRegression ' Me.mnuModelOtherGeneralRegression.Name = "mnuModelOtherGeneralRegression" - Me.mnuModelOtherGeneralRegression.Size = New System.Drawing.Size(167, 22) + Me.mnuModelOtherGeneralRegression.Size = New System.Drawing.Size(166, 22) Me.mnuModelOtherGeneralRegression.Tag = "Regression" Me.mnuModelOtherGeneralRegression.Text = "Regression..." ' 'mnuModelOtherGeneralLogLinear ' Me.mnuModelOtherGeneralLogLinear.Name = "mnuModelOtherGeneralLogLinear" - Me.mnuModelOtherGeneralLogLinear.Size = New System.Drawing.Size(167, 22) + Me.mnuModelOtherGeneralLogLinear.Size = New System.Drawing.Size(166, 22) Me.mnuModelOtherGeneralLogLinear.Tag = "Log_Linear" Me.mnuModelOtherGeneralLogLinear.Text = "Log Linear..." ' @@ -2631,7 +2630,7 @@ Partial Class frmMain ' Me.mnuTools.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.mnuToolsRunRCode, Me.mnuToolsRestartR, Me.mnuToolsCheckForUpdates, Me.mnuToolsClearOutputWindow, Me.ToolStripSeparator5, Me.mnuToolsSaveCurrentOptions, Me.mnuToolsLoadOptions, Me.mnuToolsOptions}) Me.mnuTools.Name = "mnuTools" - Me.mnuTools.Size = New System.Drawing.Size(48, 20) + Me.mnuTools.Size = New System.Drawing.Size(47, 20) Me.mnuTools.Text = "Tools" ' 'mnuToolsRunRCode diff --git a/instat/frmMain.vb b/instat/frmMain.vb index a24d65399fd..057f50c19c8 100644 --- a/instat/frmMain.vb +++ b/instat/frmMain.vb @@ -1010,4 +1010,8 @@ Public Class frmMain Private Sub mnuOrganiseDataFrameReplaceValues_Click(sender As Object, e As EventArgs) Handles mnuOrganiseDataFrameReplaceValues.Click dlgReplace.ShowDialog() End Sub + + Private Sub mnuDescribeTwoVariablesSummarise_Click(sender As Object, e As EventArgs) Handles mnuDescribeTwoVariablesSummarise.Click + dlgDescribeTwoVariable.ShowDialog() + End Sub End Class diff --git a/instat/instat.vbproj b/instat/instat.vbproj index 27d52818a07..4c0379fb7e9 100644 --- a/instat/instat.vbproj +++ b/instat/instat.vbproj @@ -135,6 +135,12 @@ + + dlgDescribeTwoVariable.vb + + + Form + ucrAxes.vb @@ -1960,6 +1966,15 @@ dlgDeleteSheet.vb + + dlgDescribeTwoVariable.vb + + + dlgDescribeTwoVariable.vb + + + dlgDescribeTwoVariable.vb + dlgDistanceText.vb diff --git a/instat/sdgDescribe.Designer.vb b/instat/sdgDescribe.Designer.vb index ea48584de84..376f7d3bab7 100644 --- a/instat/sdgDescribe.Designer.vb +++ b/instat/sdgDescribe.Designer.vb @@ -1,9 +1,9 @@ - _ + Partial Class sdgDescribe Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. - _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then @@ -20,31 +20,426 @@ Partial Class sdgDescribe 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. - _ + Private Sub InitializeComponent() Me.UcrButtonsSubdialogue1 = New instat.ucrButtonsSubdialogue() + Me.chkN = New System.Windows.Forms.CheckBox() + Me.chkNMissing = New System.Windows.Forms.CheckBox() + Me.chkNTotal = New System.Windows.Forms.CheckBox() + Me.chkMinimum = New System.Windows.Forms.CheckBox() + Me.chkMaximum = New System.Windows.Forms.CheckBox() + Me.chkRange = New System.Windows.Forms.CheckBox() + Me.chkMean = New System.Windows.Forms.CheckBox() + Me.chkMedian = New System.Windows.Forms.CheckBox() + Me.chkQuartiles = New System.Windows.Forms.CheckBox() + Me.chkHigherMoments = New System.Windows.Forms.CheckBox() + Me.chkSumSquares = New System.Windows.Forms.CheckBox() + Me.chkMeanDeviation = New System.Windows.Forms.CheckBox() + Me.chkStdDev = New System.Windows.Forms.CheckBox() + Me.chkGeometricMean = New System.Windows.Forms.CheckBox() + Me.ChkCoeffVariations = New System.Windows.Forms.CheckBox() + Me.grpPecents = New System.Windows.Forms.GroupBox() + Me.ucrInputProportions = New instat.ucrInputComboBox() + Me.ucrInputInequality = New instat.ucrInputComboBox() + Me.ucrInputPercentiles = New instat.ucrInputComboBox() + Me.chkPercentiles = New System.Windows.Forms.CheckBox() + Me.chkProportions = New System.Windows.Forms.CheckBox() + Me.chkResults = New System.Windows.Forms.CheckBox() + Me.grpPrecision = New System.Windows.Forms.GroupBox() + Me.ucrInputUnits = New instat.ucrInputComboBox() + Me.ucrInputPrecision = New instat.ucrInputComboBox() + Me.lblUnits = New System.Windows.Forms.Label() + Me.lblPrecision = New System.Windows.Forms.Label() + Me.rdoSignificantFigures = New System.Windows.Forms.RadioButton() + Me.rdoDecimals = New System.Windows.Forms.RadioButton() + Me.grpPecents.SuspendLayout() + Me.grpPrecision.SuspendLayout() Me.SuspendLayout() ' 'UcrButtonsSubdialogue1 ' - Me.UcrButtonsSubdialogue1.Location = New System.Drawing.Point(42, 222) + Me.UcrButtonsSubdialogue1.Location = New System.Drawing.Point(103, 297) Me.UcrButtonsSubdialogue1.Name = "UcrButtonsSubdialogue1" Me.UcrButtonsSubdialogue1.Size = New System.Drawing.Size(142, 30) Me.UcrButtonsSubdialogue1.TabIndex = 0 ' + 'chkN + ' + Me.chkN.AutoSize = True + Me.chkN.Location = New System.Drawing.Point(12, 9) + Me.chkN.Name = "chkN" + Me.chkN.Size = New System.Drawing.Size(34, 17) + Me.chkN.TabIndex = 1 + Me.chkN.Tag = "N" + Me.chkN.Text = "N" + Me.chkN.UseVisualStyleBackColor = True + ' + 'chkNMissing + ' + Me.chkNMissing.AutoSize = True + Me.chkNMissing.Location = New System.Drawing.Point(12, 31) + Me.chkNMissing.Name = "chkNMissing" + Me.chkNMissing.Size = New System.Drawing.Size(72, 17) + Me.chkNMissing.TabIndex = 2 + Me.chkNMissing.Tag = "N_Missing" + Me.chkNMissing.Text = "N Missing" + Me.chkNMissing.UseVisualStyleBackColor = True + ' + 'chkNTotal + ' + Me.chkNTotal.AutoSize = True + Me.chkNTotal.Location = New System.Drawing.Point(12, 53) + Me.chkNTotal.Name = "chkNTotal" + Me.chkNTotal.Size = New System.Drawing.Size(61, 17) + Me.chkNTotal.TabIndex = 3 + Me.chkNTotal.Tag = "N_Total" + Me.chkNTotal.Text = "N Total" + Me.chkNTotal.UseVisualStyleBackColor = True + ' + 'chkMinimum + ' + Me.chkMinimum.AutoSize = True + Me.chkMinimum.Location = New System.Drawing.Point(12, 75) + Me.chkMinimum.Name = "chkMinimum" + Me.chkMinimum.Size = New System.Drawing.Size(67, 17) + Me.chkMinimum.TabIndex = 4 + Me.chkMinimum.Tag = "Minimum" + Me.chkMinimum.Text = "Minimum" + Me.chkMinimum.UseVisualStyleBackColor = True + ' + 'chkMaximum + ' + Me.chkMaximum.AutoSize = True + Me.chkMaximum.Location = New System.Drawing.Point(12, 97) + Me.chkMaximum.Name = "chkMaximum" + Me.chkMaximum.Size = New System.Drawing.Size(70, 17) + Me.chkMaximum.TabIndex = 5 + Me.chkMaximum.Tag = "Maximum" + Me.chkMaximum.Text = "Maximum" + Me.chkMaximum.UseVisualStyleBackColor = True + ' + 'chkRange + ' + Me.chkRange.AutoSize = True + Me.chkRange.Location = New System.Drawing.Point(12, 119) + Me.chkRange.Name = "chkRange" + Me.chkRange.Size = New System.Drawing.Size(58, 17) + Me.chkRange.TabIndex = 6 + Me.chkRange.Tag = "Range" + Me.chkRange.Text = "Range" + Me.chkRange.UseVisualStyleBackColor = True + ' + 'chkMean + ' + Me.chkMean.AutoSize = True + Me.chkMean.Location = New System.Drawing.Point(12, 141) + Me.chkMean.Name = "chkMean" + Me.chkMean.Size = New System.Drawing.Size(53, 17) + Me.chkMean.TabIndex = 7 + Me.chkMean.Tag = "Mean" + Me.chkMean.Text = "Mean" + Me.chkMean.UseVisualStyleBackColor = True + ' + 'chkMedian + ' + Me.chkMedian.AutoSize = True + Me.chkMedian.Location = New System.Drawing.Point(172, 7) + Me.chkMedian.Name = "chkMedian" + Me.chkMedian.Size = New System.Drawing.Size(61, 17) + Me.chkMedian.TabIndex = 8 + Me.chkMedian.Tag = "Median" + Me.chkMedian.Text = "Median" + Me.chkMedian.UseVisualStyleBackColor = True + ' + 'chkQuartiles + ' + Me.chkQuartiles.AutoSize = True + Me.chkQuartiles.Location = New System.Drawing.Point(172, 31) + Me.chkQuartiles.Name = "chkQuartiles" + Me.chkQuartiles.Size = New System.Drawing.Size(67, 17) + Me.chkQuartiles.TabIndex = 9 + Me.chkQuartiles.Tag = "Quartiles" + Me.chkQuartiles.Text = "Quartiles" + Me.chkQuartiles.UseVisualStyleBackColor = True + ' + 'chkHigherMoments + ' + Me.chkHigherMoments.AutoSize = True + Me.chkHigherMoments.Location = New System.Drawing.Point(172, 55) + Me.chkHigherMoments.Name = "chkHigherMoments" + Me.chkHigherMoments.Size = New System.Drawing.Size(103, 17) + Me.chkHigherMoments.TabIndex = 10 + Me.chkHigherMoments.Tag = "Higher_Moments" + Me.chkHigherMoments.Text = "Higher Moments" + Me.chkHigherMoments.UseVisualStyleBackColor = True + ' + 'chkSumSquares + ' + Me.chkSumSquares.AutoSize = True + Me.chkSumSquares.Location = New System.Drawing.Point(172, 79) + Me.chkSumSquares.Name = "chkSumSquares" + Me.chkSumSquares.Size = New System.Drawing.Size(99, 17) + Me.chkSumSquares.TabIndex = 11 + Me.chkSumSquares.Tag = "Sum_of_squares" + Me.chkSumSquares.Text = "Sum of squares" + Me.chkSumSquares.UseVisualStyleBackColor = True + ' + 'chkMeanDeviation + ' + Me.chkMeanDeviation.AutoSize = True + Me.chkMeanDeviation.Location = New System.Drawing.Point(172, 103) + Me.chkMeanDeviation.Name = "chkMeanDeviation" + Me.chkMeanDeviation.Size = New System.Drawing.Size(101, 17) + Me.chkMeanDeviation.TabIndex = 12 + Me.chkMeanDeviation.Tag = "Mean_Deviation" + Me.chkMeanDeviation.Text = "Mean Deviation" + Me.chkMeanDeviation.UseVisualStyleBackColor = True + ' + 'chkStdDev + ' + Me.chkStdDev.AutoSize = True + Me.chkStdDev.Location = New System.Drawing.Point(12, 163) + Me.chkStdDev.Name = "chkStdDev" + Me.chkStdDev.Size = New System.Drawing.Size(117, 17) + Me.chkStdDev.TabIndex = 13 + Me.chkStdDev.Tag = "Standard_Deviation" + Me.chkStdDev.Text = "Standard Deviation" + Me.chkStdDev.UseVisualStyleBackColor = True + ' + 'chkGeometricMean + ' + Me.chkGeometricMean.AutoSize = True + Me.chkGeometricMean.Location = New System.Drawing.Point(172, 127) + Me.chkGeometricMean.Name = "chkGeometricMean" + Me.chkGeometricMean.Size = New System.Drawing.Size(104, 17) + Me.chkGeometricMean.TabIndex = 14 + Me.chkGeometricMean.Tag = "Geometric_Mean" + Me.chkGeometricMean.Text = "Geometric Mean" + Me.chkGeometricMean.UseVisualStyleBackColor = True + ' + 'ChkCoeffVariations + ' + Me.ChkCoeffVariations.AutoSize = True + Me.ChkCoeffVariations.Location = New System.Drawing.Point(172, 151) + Me.ChkCoeffVariations.Name = "ChkCoeffVariations" + Me.ChkCoeffVariations.Size = New System.Drawing.Size(137, 17) + Me.ChkCoeffVariations.TabIndex = 15 + Me.ChkCoeffVariations.Tag = "Coefficient_of_Variations" + Me.ChkCoeffVariations.Text = "Coefficient of Variations" + Me.ChkCoeffVariations.UseVisualStyleBackColor = True + ' + 'grpPecents + ' + Me.grpPecents.Controls.Add(Me.ucrInputProportions) + Me.grpPecents.Controls.Add(Me.ucrInputInequality) + Me.grpPecents.Controls.Add(Me.ucrInputPercentiles) + Me.grpPecents.Controls.Add(Me.chkPercentiles) + Me.grpPecents.Controls.Add(Me.chkProportions) + Me.grpPecents.Controls.Add(Me.chkResults) + Me.grpPecents.Location = New System.Drawing.Point(11, 185) + Me.grpPecents.Name = "grpPecents" + Me.grpPecents.Size = New System.Drawing.Size(185, 109) + Me.grpPecents.TabIndex = 16 + Me.grpPecents.TabStop = False + ' + 'ucrInputProportions + ' + Me.ucrInputProportions.IsReadOnly = False + Me.ucrInputProportions.Location = New System.Drawing.Point(118, 53) + Me.ucrInputProportions.Name = "ucrInputProportions" + Me.ucrInputProportions.Size = New System.Drawing.Size(50, 21) + Me.ucrInputProportions.TabIndex = 23 + ' + 'ucrInputInequality + ' + Me.ucrInputInequality.IsReadOnly = False + Me.ucrInputInequality.Location = New System.Drawing.Point(85, 53) + Me.ucrInputInequality.Name = "ucrInputInequality" + Me.ucrInputInequality.Size = New System.Drawing.Size(28, 21) + Me.ucrInputInequality.TabIndex = 22 + ' + 'ucrInputPercentiles + ' + Me.ucrInputPercentiles.IsReadOnly = False + Me.ucrInputPercentiles.Location = New System.Drawing.Point(88, 16) + Me.ucrInputPercentiles.Name = "ucrInputPercentiles" + Me.ucrInputPercentiles.Size = New System.Drawing.Size(84, 21) + Me.ucrInputPercentiles.TabIndex = 21 + ' + 'chkPercentiles + ' + Me.chkPercentiles.AutoSize = True + Me.chkPercentiles.Location = New System.Drawing.Point(7, 19) + Me.chkPercentiles.Name = "chkPercentiles" + Me.chkPercentiles.Size = New System.Drawing.Size(78, 17) + Me.chkPercentiles.TabIndex = 18 + Me.chkPercentiles.Tag = "Percentiles" + Me.chkPercentiles.Text = "Percentiles" + Me.chkPercentiles.UseVisualStyleBackColor = True + ' + 'chkProportions + ' + Me.chkProportions.AutoSize = True + Me.chkProportions.Location = New System.Drawing.Point(7, 53) + Me.chkProportions.Name = "chkProportions" + Me.chkProportions.Size = New System.Drawing.Size(79, 17) + Me.chkProportions.TabIndex = 19 + Me.chkProportions.Tag = "Proportions" + Me.chkProportions.Text = "Proportions" + Me.chkProportions.UseVisualStyleBackColor = True + ' + 'chkResults + ' + Me.chkResults.AutoSize = True + Me.chkResults.Location = New System.Drawing.Point(75, 84) + Me.chkResults.Name = "chkResults" + Me.chkResults.Size = New System.Drawing.Size(86, 17) + Me.chkResults.TabIndex = 20 + Me.chkResults.Tag = "Results_as_%" + Me.chkResults.Text = "Results as %" + Me.chkResults.UseVisualStyleBackColor = True + ' + 'grpPrecision + ' + Me.grpPrecision.Controls.Add(Me.ucrInputUnits) + Me.grpPrecision.Controls.Add(Me.ucrInputPrecision) + Me.grpPrecision.Controls.Add(Me.lblUnits) + Me.grpPrecision.Controls.Add(Me.lblPrecision) + Me.grpPrecision.Controls.Add(Me.rdoSignificantFigures) + Me.grpPrecision.Controls.Add(Me.rdoDecimals) + Me.grpPrecision.Location = New System.Drawing.Point(198, 185) + Me.grpPrecision.Name = "grpPrecision" + Me.grpPrecision.Size = New System.Drawing.Size(161, 109) + Me.grpPrecision.TabIndex = 17 + Me.grpPrecision.TabStop = False + ' + 'ucrInputUnits + ' + Me.ucrInputUnits.IsReadOnly = False + Me.ucrInputUnits.Location = New System.Drawing.Point(43, 70) + Me.ucrInputUnits.Name = "ucrInputUnits" + Me.ucrInputUnits.Size = New System.Drawing.Size(43, 21) + Me.ucrInputUnits.TabIndex = 23 + ' + 'ucrInputPrecision + ' + Me.ucrInputPrecision.IsReadOnly = False + Me.ucrInputPrecision.Location = New System.Drawing.Point(60, 15) + Me.ucrInputPrecision.Name = "ucrInputPrecision" + Me.ucrInputPrecision.Size = New System.Drawing.Size(58, 21) + Me.ucrInputPrecision.TabIndex = 22 + ' + 'lblUnits + ' + Me.lblUnits.AccessibleDescription = "" + Me.lblUnits.AutoSize = True + Me.lblUnits.Location = New System.Drawing.Point(6, 73) + Me.lblUnits.Name = "lblUnits" + Me.lblUnits.Size = New System.Drawing.Size(31, 13) + Me.lblUnits.TabIndex = 3 + Me.lblUnits.Tag = "Units" + Me.lblUnits.Text = "Units" + ' + 'lblPrecision + ' + Me.lblPrecision.AccessibleDescription = "v" + Me.lblPrecision.AutoSize = True + Me.lblPrecision.Location = New System.Drawing.Point(6, 16) + Me.lblPrecision.Name = "lblPrecision" + Me.lblPrecision.Size = New System.Drawing.Size(50, 13) + Me.lblPrecision.TabIndex = 2 + Me.lblPrecision.Tag = "Precision" + Me.lblPrecision.Text = "Precision" + ' + 'rdoSignificantFigures + ' + Me.rdoSignificantFigures.AutoSize = True + Me.rdoSignificantFigures.Location = New System.Drawing.Point(71, 47) + Me.rdoSignificantFigures.Name = "rdoSignificantFigures" + Me.rdoSignificantFigures.Size = New System.Drawing.Size(80, 17) + Me.rdoSignificantFigures.TabIndex = 1 + Me.rdoSignificantFigures.TabStop = True + Me.rdoSignificantFigures.Tag = "Sig_Figures" + Me.rdoSignificantFigures.Text = "Sig. Figures" + Me.rdoSignificantFigures.UseVisualStyleBackColor = True + ' + 'rdoDecimals + ' + Me.rdoDecimals.AutoSize = True + Me.rdoDecimals.Location = New System.Drawing.Point(4, 47) + Me.rdoDecimals.Name = "rdoDecimals" + Me.rdoDecimals.Size = New System.Drawing.Size(68, 17) + Me.rdoDecimals.TabIndex = 0 + Me.rdoDecimals.TabStop = True + Me.rdoDecimals.Tag = "Decimals" + Me.rdoDecimals.Text = "Decimals" + Me.rdoDecimals.UseVisualStyleBackColor = True + ' 'sdgDescribe ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(284, 261) + Me.ClientSize = New System.Drawing.Size(364, 332) + Me.Controls.Add(Me.grpPrecision) + Me.Controls.Add(Me.grpPecents) + Me.Controls.Add(Me.ChkCoeffVariations) + Me.Controls.Add(Me.chkGeometricMean) + Me.Controls.Add(Me.chkMeanDeviation) + Me.Controls.Add(Me.chkSumSquares) + Me.Controls.Add(Me.chkHigherMoments) + Me.Controls.Add(Me.chkQuartiles) + Me.Controls.Add(Me.chkMedian) + Me.Controls.Add(Me.chkStdDev) + Me.Controls.Add(Me.chkMean) + Me.Controls.Add(Me.chkRange) + Me.Controls.Add(Me.chkMaximum) + Me.Controls.Add(Me.chkMinimum) + Me.Controls.Add(Me.chkNTotal) + Me.Controls.Add(Me.chkNMissing) + Me.Controls.Add(Me.chkN) Me.Controls.Add(Me.UcrButtonsSubdialogue1) Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "sdgDescribe" Me.Text = "sdgDescribe" + Me.grpPecents.ResumeLayout(False) + Me.grpPecents.PerformLayout() + Me.grpPrecision.ResumeLayout(False) + Me.grpPrecision.PerformLayout() Me.ResumeLayout(False) + Me.PerformLayout() End Sub Friend WithEvents UcrButtonsSubdialogue1 As ucrButtonsSubdialogue + Friend WithEvents chkN As CheckBox + Friend WithEvents chkNMissing As CheckBox + Friend WithEvents chkNTotal As CheckBox + Friend WithEvents chkMinimum As CheckBox + Friend WithEvents chkMaximum As CheckBox + Friend WithEvents chkRange As CheckBox + Friend WithEvents chkMean As CheckBox + Friend WithEvents chkMedian As CheckBox + Friend WithEvents chkQuartiles As CheckBox + Friend WithEvents chkHigherMoments As CheckBox + Friend WithEvents chkSumSquares As CheckBox + Friend WithEvents chkMeanDeviation As CheckBox + Friend WithEvents chkStdDev As CheckBox + Friend WithEvents chkGeometricMean As CheckBox + Friend WithEvents ChkCoeffVariations As CheckBox + Friend WithEvents grpPecents As GroupBox + Friend WithEvents grpPrecision As GroupBox + Friend WithEvents ucrInputProportions As ucrInputComboBox + Friend WithEvents ucrInputInequality As ucrInputComboBox + Friend WithEvents ucrInputPercentiles As ucrInputComboBox + Friend WithEvents chkPercentiles As CheckBox + Friend WithEvents chkProportions As CheckBox + Friend WithEvents chkResults As CheckBox + Friend WithEvents ucrInputUnits As ucrInputComboBox + Friend WithEvents ucrInputPrecision As ucrInputComboBox + Friend WithEvents lblUnits As Label + Friend WithEvents lblPrecision As Label + Friend WithEvents rdoSignificantFigures As RadioButton + Friend WithEvents rdoDecimals As RadioButton End Class + diff --git a/instat/sdgDescribe.vb b/instat/sdgDescribe.vb index 4f2373f73fe..b14e95696c2 100644 --- a/instat/sdgDescribe.vb +++ b/instat/sdgDescribe.vb @@ -18,4 +18,14 @@ Public Class sdgDescribe Private Sub sdgDescribe_Load(sender As Object, e As EventArgs) Handles MyBase.Load autoTranslate(Me) End Sub + + Public Sub SetDefaults() + chkMean.Checked = True + chkStdDev.Checked = True + chkMinimum.Checked = True + chkMaximum.Checked = True + chkNMissing.Checked = True + chkN.Checked = True + chkNTotal.Checked = True + End Sub End Class \ No newline at end of file diff --git a/instat/sdgPlots.vb b/instat/sdgPlots.vb index a9225bec550..d3ae3d5d8e4 100644 --- a/instat/sdgPlots.vb +++ b/instat/sdgPlots.vb @@ -69,6 +69,14 @@ Public Class sdgPlots clsRggplotFunction = clsGgplotFunc End Sub + Public Sub me_me() Handles tabctrlBoxSubdialog.TabIndexChanged + If tabctrlBoxSubdialog.SelectedTab Is tbpXAxis Then + ucrXAxis.bIsX = True + ElseIf tabctrlBoxSubdialog.SelectedTab Is tbpYAxis Then + ucrYAxis.bIsX = False + End If + End Sub + Private Sub Themes() ucrInputThemes.cboInput.Items.AddRange({"default", "theme_bw", "theme_linedraw", "theme_light", "theme_minimal", "theme_classic", "theme_dark", "theme_void", "theme_base", "theme_calc", "theme_economist", "theme_few", "theme_fivethirtyeight", "theme_foundation", "theme_gdocs", "theme_igray", "theme_map", "theme_par", "theme_solarized", "theme_hc", "theme_pander", "theme_solid", "theme_stata", "theme_tufte", "theme_wsj"}) cmdAllOptions.Enabled = False @@ -285,7 +293,6 @@ Public Class sdgPlots Public Sub SetRsyntaxAxis(clsRsyntaxAxis As RSyntax) clsRsyntax = clsRsyntaxAxis End Sub - Private Sub ucrInputGraphTitle_NameChanged() Handles ucrInputGraphTitle.NameChanged If Not ucrInputGraphTitle.IsEmpty Then clsGraphTitleFunction.SetRCommand("ggtitle") diff --git a/instat/static/InstatObject/R/Backend_Components/calculations.R b/instat/static/InstatObject/R/Backend_Components/calculations.R index f02a0f334e5..21af0344d2f 100644 --- a/instat/static/InstatObject/R/Backend_Components/calculations.R +++ b/instat/static/InstatObject/R/Backend_Components/calculations.R @@ -2,13 +2,15 @@ calculation <- R6Class("calculation", public = list( initialize = function(function_name = "", parameters = list(), calculated_from = c(), is_recalculable = TRUE, - sub_calculations = list(), type = "", filter_list = list()) { + sub_calculations = list(), type = "", filter_list = list(), + name = "") { self$function_name = function_name self$parameters = parameters self$calculated_from = c() self$is_recalculable = is_recalculable self$sub_calculations = sub_calculations self$type = type + self$name = name private$.filter_list = filter_list }, function_name = "", diff --git a/instat/static/InstatObject/R/Backend_Components/summary_functions.R b/instat/static/InstatObject/R/Backend_Components/summary_functions.R index a66a3606911..996a03d757d 100644 --- a/instat/static/InstatObject/R/Backend_Components/summary_functions.R +++ b/instat/static/InstatObject/R/Backend_Components/summary_functions.R @@ -92,11 +92,10 @@ data_object$set("public", "calculate_summary", function(columns_to_summarise, su if(!all(columns_to_summarise %in% names(private$data))) stop(paste("Some of the columns from:",paste(columns_to_summarise, collapse = ","),"were not found in the data.")) if(!all(summaries %in% all_summaries)) stop(paste("Some of the summaries from:",paste(summaries, collapse = ","),"were not recognised.")) if(!all(factors %in% names(private$data))) stop(paste("Some of the factors:","c(",paste(factors, collapse = ","),") were not found in the data.")) - combinations = expand.grid(summaries,columns_to_summarise) if(length(summaries)==1) { if(length(columns_to_summarise) == 1) out = ddply(private$data, factors, function(x) match.fun(summaries)(x[[columns_to_summarise]],...), .drop = drop) - else out = ddply(private$data, factors, function(x) sapply(columns_to_summarise, function(y) match.fun(summaries)(x[[y]]),...), .drop = drop) + else out = ddply(private$data, factors, function(x) sapply(columns_to_summarise, function(y) match.fun(summaries)(x[[y]],...)), .drop = drop) } else { if(length(columns_to_summarise) == 1) out = ddply(private$data, factors, function(x) sapply(summaries, function(y) match.fun(y)(x[[columns_to_summarise]],...)), .drop = drop) diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index 3ce88275bcd..99adeae47e7 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -77,16 +77,8 @@ data_object <- R6Class("data_object", }, current_filter = function(filter) { if(missing(filter)) { - filter_string = "" #TODO Change this to call get_filter_as_logical - i = 1 - result = matrix(nrow = nrow(private$data), ncol = length(private$.current_filter$filter_list)) - for(condition in private$.current_filter$filter_list) { - func = match.fun(condition[["operation"]]) - result[ ,i] = func(self$get_columns_from_data(condition[["column"]], use_current_filter = FALSE), condition[["value"]]) - i = i + 1 - } - return(apply(result, 1, all)) + return(self$get_filter_as_logical(private$.current_filter$name)) } else { private$.current_filter <- filter @@ -497,8 +489,14 @@ data_object$set("public", "replace_value_in_data", function(col_names, rows, old } else { if(filter_applied) stop("Cannot replace values in a factor column when a filter is applied. Remove the filter to do this replacement.") - self$edit_factor_level(col_name = col_name, old_level = old_value, new_level = new_value) - done = TRUE + if(is.na(old_value)) { + if(!new_value %in% levels(private$data[[col_name]])) stop(new_value, " is not a level of this factor. Add this as a level of the factor before using replace.") + replace_rows <- (is.na(curr_column)) + } + else { + self$edit_factor_level(col_name = col_name, old_level = old_value, new_level = new_value) + done = TRUE + } } } else if(str_data_type == "integer" || str_data_type == "numeric") { @@ -529,7 +527,8 @@ data_object$set("public", "replace_value_in_data", function(col_names, rows, old } } else { - replace_rows <- (curr_column == old_value) + if(is.na(old_value)) replace_rows <- (is.na(curr_column)) + else replace_rows <- (curr_column == old_value) } } } @@ -538,7 +537,10 @@ data_object$set("public", "replace_value_in_data", function(col_names, rows, old replace_rows <- (data_row_names %in% rows) if(!missing(old_value)) warning("old_value will be ignored because rows has been specified.") } - else replace_rows <- (curr_column == old_value) + else { + if(is.na(old_value)) replace_rows <- (is.na(curr_column)) + else replace_rows <- (curr_column == old_value) + } new_value <- as.character(new_value) } else if(str_data_type == "logical") { @@ -548,7 +550,10 @@ data_object$set("public", "replace_value_in_data", function(col_names, rows, old replace_rows <- (data_row_names %in% rows) if(!missing(old_value)) warning("old_value will be ignored because rows has been specified.") } - else replace_rows <- (curr_column == old_value) + else { + if(is.na(old_value)) replace_rows <- (is.na(curr_column)) + else replace_rows <- (curr_column == old_value) + } } #TODO add other data type cases else { @@ -556,9 +561,13 @@ data_object$set("public", "replace_value_in_data", function(col_names, rows, old replace_rows <- (data_row_names %in% rows) if(!missing(old_value)) warning("old_value will be ignored because rows has been specified.") } - replace_rows <- (curr_column == old_value) + else { + if(is.na(old_value)) replace_rows <- (is.na(curr_column)) + else replace_rows <- (curr_column == old_value) + } } if(!done) { + replace_rows[is.na(replace_rows)] <- FALSE if(sum(replace_rows) > 0) { if(filter_applied) { replace_rows <- replace_rows & curr_filter @@ -686,7 +695,8 @@ data_object$set("public", "add_defaults_variables_metadata", function() { data_object$set("public", "remove_rows_in_data", function(row_names) { if(!all(row_names %in% rownames(private$data))) stop("Some of the row_names not found in data") - self$set_data(private$data[!(rownames(private$data) %in% row_names), ]) + rows_to_remove <- which(rownames(private$data) %in% row_names) + self$set_data(slice(private$data, -rows_to_remove)) self$append_to_changes(list(Removed_row, row_names)) self$data_changed <- TRUE } @@ -1059,7 +1069,7 @@ data_object$set("public", "set_protected_columns", function(col_names) { } ) -data_object$set("public", "add_filter", function(filter, filter_name = "", replace = TRUE, set_as_current = FALSE) { +data_object$set("public", "add_filter", function(filter, filter_name = "", replace = TRUE, set_as_current = FALSE, na.rm = TRUE) { if(missing(filter)) stop("filter is required") if(filter_name == "") filter_name = next_default_item("Filter", names(private$filters)) @@ -1074,7 +1084,7 @@ data_object$set("public", "add_filter", function(filter, filter_name = "", repla } else { if(filter_name %in% names(private$filters)) message("A filter named ", filter_name, " already exists. It will be replaced by the new filter.") - filter_calc = calculation$new(type = "filter", filter_list = filter) + filter_calc = calculation$new(type = "filter", filter_list = filter, name = filter_name, parameters = list(na.rm = na.rm)) private$filters[[filter_name]] <- filter_calc self$append_to_changes(list(Added_filter, filter_name)) if(set_as_current) { @@ -1128,7 +1138,9 @@ data_object$set("public", "get_filter_as_logical", function(filter_name) { result[ ,i] = func(self$get_columns_from_data(condition[["column"]], use_current_filter = FALSE), condition[["value"]]) i = i + 1 } - return(apply(result, 1, all)) + out <- apply(result, 1, all) + out[is.na(out)] <- !private$filters[[filter_name]]$parameters[["na.rm"]] + return(out) } ) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index 5a79c768a4d..cb3a0e37245 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -315,27 +315,27 @@ instat_object$set("public", "get_data_changed", function(data_name) { } ) -instat_object$set("public", "get_variables_metadata_changed", function(data_obj) { - if(missing(data_obj)) { +instat_object$set("public", "get_variables_metadata_changed", function(data_name) { + if(missing(data_name)) { if(private$.data_objects_changed) return(TRUE) return(any(sapply(private$.data_objects, function(x) x$variables_metadata_changed))) } else { - return(self$get_data_objects(data_obj)$variables_metadata_changed) + return(self$get_data_objects(data_name)$variables_metadata_changed) } } ) -instat_object$set("public", "get_metadata_changed", function(data_obj) { - if(missing(data_obj)) { - if(private$.data_objects_changed) return (TRUE) +instat_object$set("public", "get_metadata_changed", function(data_name) { + if(missing(data_name)) { + if(private$.data_objects_changed) return(TRUE) for(curr_obj in private$.data_objects) { if(curr_obj$metadata_changed) return(TRUE) } return(FALSE) } else { - return(self$get_data_objects(data_obj)$metadata_changed) + return(self$get_data_objects(data_name)$metadata_changed) } } ) @@ -565,9 +565,9 @@ instat_object$set("public", "get_graph_names", function(data_name, include_overa } ) -instat_object$set("public", "add_filter", function(data_name, filter, filter_name = "", replace = TRUE, set_as_current_filter = FALSE) { +instat_object$set("public", "add_filter", function(data_name, filter, filter_name = "", replace = TRUE, set_as_current_filter = FALSE, na.rm = TRUE) { if(missing(filter)) stop("filter is required") - self$get_data_objects(data_name)$add_filter(filter, filter_name, replace, set_as_current_filter) + self$get_data_objects(data_name)$add_filter(filter, filter_name, replace, set_as_current_filter, na.rm = na.rm) } ) diff --git a/instat/ucrAxes.Designer.vb b/instat/ucrAxes.Designer.vb index 7268d7b3244..42775af403a 100644 --- a/instat/ucrAxes.Designer.vb +++ b/instat/ucrAxes.Designer.vb @@ -29,6 +29,7 @@ Partial Class ucrAxes Me.chkOverwriteTitle = New System.Windows.Forms.CheckBox() Me.chkDisplayTitle = New System.Windows.Forms.CheckBox() Me.grpTickMarkers = New System.Windows.Forms.GroupBox() + Me.ucrTickMarkers = New instat.ucrInputComboBox() Me.lblTickMarkersNoOfDecimalPlaces = New System.Windows.Forms.Label() Me.nudTickMarkersNoOfDecimalPlaces = New System.Windows.Forms.NumericUpDown() Me.rdoTickMarkersAuto = New System.Windows.Forms.RadioButton() @@ -49,7 +50,6 @@ Partial Class ucrAxes Me.lblLowerLimit = New System.Windows.Forms.Label() Me.rdoScalesCustom = New System.Windows.Forms.RadioButton() Me.rdoScalesAuto = New System.Windows.Forms.RadioButton() - Me.ucrTickMarkers = New instat.ucrInputComboBox() Me.grpAxisTitle.SuspendLayout() Me.grpTickMarkers.SuspendLayout() CType(Me.nudTickMarkersNoOfDecimalPlaces, System.ComponentModel.ISupportInitialize).BeginInit() @@ -147,6 +147,14 @@ Partial Class ucrAxes Me.grpTickMarkers.TabStop = False Me.grpTickMarkers.Text = "Tick Markers" ' + 'ucrTickMarkers + ' + Me.ucrTickMarkers.IsReadOnly = False + Me.ucrTickMarkers.Location = New System.Drawing.Point(6, 51) + Me.ucrTickMarkers.Name = "ucrTickMarkers" + Me.ucrTickMarkers.Size = New System.Drawing.Size(137, 21) + Me.ucrTickMarkers.TabIndex = 16 + ' 'lblTickMarkersNoOfDecimalPlaces ' Me.lblTickMarkersNoOfDecimalPlaces.AutoSize = True @@ -177,7 +185,7 @@ Partial Class ucrAxes 'ucrSpecificValues ' Me.ucrSpecificValues.IsReadOnly = False - Me.ucrSpecificValues.Location = New System.Drawing.Point(6, 88) + Me.ucrSpecificValues.Location = New System.Drawing.Point(6, 78) Me.ucrSpecificValues.Name = "ucrSpecificValues" Me.ucrSpecificValues.Size = New System.Drawing.Size(173, 21) Me.ucrSpecificValues.TabIndex = 15 @@ -328,14 +336,6 @@ Partial Class ucrAxes Me.rdoScalesAuto.Text = "Auto" Me.rdoScalesAuto.UseVisualStyleBackColor = True ' - 'ucrTickMarkers - ' - Me.ucrTickMarkers.IsReadOnly = False - Me.ucrTickMarkers.Location = New System.Drawing.Point(6, 51) - Me.ucrTickMarkers.Name = "ucrTickMarkers" - Me.ucrTickMarkers.Size = New System.Drawing.Size(137, 21) - Me.ucrTickMarkers.TabIndex = 16 - ' 'ucrAxes ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) diff --git a/instat/ucrAxes.vb b/instat/ucrAxes.vb index 6d17709a67c..f11d79fbe70 100644 --- a/instat/ucrAxes.vb +++ b/instat/ucrAxes.vb @@ -19,6 +19,9 @@ Public Class ucrAxes Public clsRsyntax As New RSyntax Public clsRggplotFunction As New RFunction Public clsTitleFunction As New RFunction + Public clsScalecontinuousFunction As New RFunction + Public clsSeqFunction As New RFunction + Public strAxis As String Public bFirstLoad As Boolean = True Private Sub ucrAxes_Load(sender As Object, e As EventArgs) Handles Me.Load @@ -39,7 +42,8 @@ Public Class ucrAxes End Sub Private Sub InitialiseControl() - ucrTickMarkers.cboInput.Items.Add({"Interval", "Specific Values"}) + ucrTickMarkers.cboInput.Items.Add("Interval") + ucrTickMarkers.cboInput.Items.Add("Specific Values") ucrTickMarkers.SetName("Interval") TitleDefaults() ScalesDefaults() @@ -90,7 +94,7 @@ Public Class ucrAxes nudTickMarkersNoOfDecimalPlaces.Visible = False ucrSpecificValues.Visible = False ElseIf rdoTickMarkersCustom.Checked Then - ucrTickMarkers.Visible = False + ucrTickMarkers.Visible = True lblFrom.Visible = True nudFrom.Visible = True lblTo.Visible = True @@ -103,13 +107,21 @@ Public Class ucrAxes End If End Sub - Public Sub SetXorY(bIsX) - If bIsX = True Then + Public Sub SetXorY(bIsXAxis As Boolean) + If bIsXAxis = True Then + bIsX = True + strAxis = "x" clsTitleFunction.SetRCommand("xlab") + clsScalecontinuousFunction.SetRCommand("scale_" & strAxis & "_continuous") + ' put scale_x_continuous function here - ElseIf bIsX = False Then + ElseIf bIsXAxis = False Then + bIsX = False + strAxis = "y" clsTitleFunction.SetRCommand("ylab") + clsScalecontinuousFunction.SetRCommand("scale_" & strAxis & "_continuous") ' put scale_y_continuous function here + End If End Sub @@ -121,13 +133,22 @@ Public Class ucrAxes If rdoTitleCustom.Checked AndAlso chkDisplayTitle.Checked Then If chkOverwriteTitle.Checked AndAlso Not ucrOverwriteTitle.IsEmpty Then clsTitleFunction.AddParameter("label", Chr(34) & ucrOverwriteTitle.GetText & Chr(34)) - clsRsyntax.AddOperatorParameter("axistitle", clsRFunc:=clsTitleFunction) + clsRsyntax.AddOperatorParameter(strAxis & "axistitle", clsRFunc:=clsTitleFunction) Else - clsRsyntax.RemoveOperatorParameter("axistitle") + clsRsyntax.RemoveOperatorParameter(strAxis & "axistitle") End If Else clsTitleFunction.AddParameter("label", Chr(34) & "" & Chr(34)) - clsRsyntax.AddOperatorParameter("axistitle", clsRFunc:=clsTitleFunction) + clsRsyntax.AddOperatorParameter(strAxis & "axistitle", clsRFunc:=clsTitleFunction) + End If + End Sub + + Private Sub ScalesFunction() + If rdoScalesCustom.Checked Then + clsScalecontinuousFunction.AddParameter("limits", "c(" & nudLowerLimit.Value & "," & nudUpperLimit.Value & ")") + clsRsyntax.AddOperatorParameter("scale_" & strAxis & "_continuous", clsRFunc:=clsScalecontinuousFunction) + Else + clsRsyntax.RemoveOperatorParameter("scale_" & strAxis & "_continuous") End If End Sub @@ -184,4 +205,74 @@ Public Class ucrAxes Private Sub rdoTickMarkersCustom_CheckedChanged(sender As Object, e As EventArgs) Handles rdoTickMarkersCustom.CheckedChanged TickMarkersDefaults() End Sub + + Private Sub nudLowerLimit_TextChanged(sender As Object, e As EventArgs) Handles nudLowerLimit.TextChanged, nudUpperLimit.TextChanged + ScalesFunction() + End Sub + Private Sub nudScalesNoOfDecimalPlaces_TextChanged(sender As Object, e As EventArgs) Handles nudScalesNoOfDecimalPlaces.TextChanged + nudUpperLimit.DecimalPlaces = nudScalesNoOfDecimalPlaces.Value + nudLowerLimit.DecimalPlaces = nudScalesNoOfDecimalPlaces.Value + End Sub + + Private Sub nudTickMarkersNoOfDecimalPlaces_TextChanged(sender As Object, e As EventArgs) Handles nudTickMarkersNoOfDecimalPlaces.TextChanged + nudFrom.DecimalPlaces = nudTickMarkersNoOfDecimalPlaces.Value + nudTo.DecimalPlaces = nudTickMarkersNoOfDecimalPlaces.Value + nudInStepsOf.DecimalPlaces = nudTickMarkersNoOfDecimalPlaces.Value + End Sub + + Private Sub ucrTickMarkers_NameChanged() Handles ucrTickMarkers.NameChanged + If ucrTickMarkers.cboInput.SelectedItem = "Interval" Then + clsSeqFunction.SetRCommand("seq") + clsScalecontinuousFunction.AddParameter("breaks", clsRFunctionParameter:=clsSeqFunction) + + ElseIf ucrTickMarkers.cboInput.SelectedItem = "Specific Values" Then + clsScalecontinuousFunction.RemoveParameterByName("breaks") + ucrSpecificValues.Visible = True + lblFrom.Visible = False + nudFrom.Visible = False + lblTo.Visible = False + nudTo.Visible = False + lblInStepsOf.Visible = False + nudInStepsOf.Visible = False + lblTickMarkersNoOfDecimalPlaces.Visible = False + nudTickMarkersNoOfDecimalPlaces.Visible = False + End If + End Sub + + Private Sub TickMarkersInterval() + + End Sub + + Private Sub ucrSpecificValues_NameChanged() Handles ucrSpecificValues.NameChanged + If Not ucrSpecificValues.IsEmpty Then + clsScalecontinuousFunction.AddParameter("breaks", "c(" & ucrSpecificValues.GetText & ")") + Else + clsScalecontinuousFunction.RemoveParameterByName("breaks") + End If + End Sub + + Private Sub nudFrom_TextChanged(sender As Object, e As EventArgs) Handles nudFrom.TextChanged + If nudFrom.Text <> "" Then + clsSeqFunction.AddParameter("from", nudFrom.Value) + Else + clsSeqFunction.RemoveParameterByName("from") + End If + End Sub + + Private Sub nudTo_TextChanged(sender As Object, e As EventArgs) Handles nudTo.TextChanged + If nudTo.Text <> "" Then + clsSeqFunction.AddParameter("to", nudTo.Value) + Else + clsSeqFunction.RemoveParameterByName("to") + End If + End Sub + + Private Sub nudInStepsOf_TextChanged(sender As Object, e As EventArgs) Handles nudInStepsOf.TextChanged + If nudFrom.Text <> "" Then + clsSeqFunction.AddParameter("by", nudFrom.Value) + Else + clsSeqFunction.RemoveParameterByName("by") + End If + End Sub End Class + diff --git a/instat/ucrButtons.vb b/instat/ucrButtons.vb index 969c0ac639b..73f9d4a7206 100644 --- a/instat/ucrButtons.vb +++ b/instat/ucrButtons.vb @@ -48,12 +48,18 @@ Public Class ucrButtons Private Sub cmdOk_Click(sender As Object, e As EventArgs) Handles cmdOk.Click Dim strComments As String = "" + Dim bIsAssigned As Boolean + Dim bToBeAssigned As Boolean + Dim strAssignTo As String RaiseEvent BeforeClickOk(sender, e) If chkComment.Checked Then strComments = txtComment.Text End If + bIsAssigned = clsRsyntax.GetbIsAssigned() + bToBeAssigned = clsRsyntax.GetbToBeAssigned() + strAssignTo = clsRsyntax.GetstrAssignTo() frmMain.clsRLink.RunScript(clsRsyntax.GetScript(), clsRsyntax.iCallType, strComment:=strComments) 'This clears the script after it has been run, but leave the function and parameters in the base function @@ -61,7 +67,9 @@ Public Class ucrButtons clsRsyntax.strScript = "" RaiseEvent ClickOk(sender, e) - + clsRsyntax.SetbIsAssigned(bIsAssigned) + clsRsyntax.SetbToBeAssigned(bToBeAssigned) + clsRsyntax.SetstrAssignTo(strAssignTo) Me.ParentForm.Hide() End Sub diff --git a/instat/ucrFactor.vb b/instat/ucrFactor.vb index 037efa3a9a3..0425d0581a4 100644 --- a/instat/ucrFactor.vb +++ b/instat/ucrFactor.vb @@ -99,9 +99,17 @@ Public Class ucrFactor Private Sub RefreshFactorData() Dim dfTemp As CharacterMatrix Dim bShowGrid As Boolean = False + Dim clsGetFactorData As New RFunction + Dim clsConvertToCharacter As New RFunction + grdFactorData.Worksheets.Clear() - If clsReceiver IsNot Nothing AndAlso Not clsReceiver.IsEmpty() AndAlso clsReceiver.strCurrDataType = "factor" Then - dfTemp = frmMain.clsRLink.GetData(frmMain.clsRLink.strInstatDataObject & "$get_factor_data_frame(data_name = " & Chr(34) & clsReceiver.GetDataName() & Chr(34) & ", col_name = " & clsReceiver.GetVariableNames() & ")") + If clsReceiver IsNot Nothing AndAlso Not clsReceiver.IsEmpty() AndAlso clsReceiver.strCurrDataType = "factor" Then + clsGetFactorData.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$get_factor_data_frame") + clsGetFactorData.AddParameter("data_name", Chr(34) & clsReceiver.GetDataName() & Chr(34)) + clsGetFactorData.AddParameter("col_name", clsReceiver.GetVariableNames()) + clsConvertToCharacter.SetRCommand("convert_to_character_matrix") + clsConvertToCharacter.AddParameter("data", clsRFunctionParameter:=clsGetFactorData) + dfTemp = frmMain.clsRLink.RunInternalScriptGetValue(clsConvertToCharacter.ToScript()).AsCharacterMatrix frmMain.clsGrids.FillSheet(dfTemp, "Factor Data", grdFactorData) shtCurrSheet = grdFactorData.CurrentWorksheet bShowGrid = True diff --git a/instat/ucrInput.vb b/instat/ucrInput.vb index 115a469fa91..b875a0bac6b 100644 --- a/instat/ucrInput.vb +++ b/instat/ucrInput.vb @@ -341,7 +341,7 @@ Public Class ucrInput If Not bUserTyped Then SetDefaultName() End If - RaiseEvent NameChanged() + 'RaiseEvent NameChanged() End Sub Private Sub ucrInput_TextChanged(sender As Object, e As EventArgs) Handles Me.TextChanged diff --git a/instat/ucrReceiverSingle.vb b/instat/ucrReceiverSingle.vb index 52fc3ee4bd3..b76baa8ae07 100644 --- a/instat/ucrReceiverSingle.vb +++ b/instat/ucrReceiverSingle.vb @@ -65,9 +65,11 @@ Public Class ucrReceiverSingle End If Next End If - clsGetDataType.AddParameter("data_name", Chr(34) & strDataFrame & Chr(34)) - clsGetDataType.AddParameter("column", Chr(34) & strItem & Chr(34)) - strCurrDataType = frmMain.clsRLink.RunInternalScriptGetValue(clsGetDataType.ToScript()).AsCharacter(0) + If strDataFrame <> "" Then + clsGetDataType.AddParameter("data_name", Chr(34) & strDataFrame & Chr(34)) + clsGetDataType.AddParameter("column", Chr(34) & strItem & Chr(34)) + strCurrDataType = frmMain.clsRLink.RunInternalScriptGetValue(clsGetDataType.ToScript()).AsCharacter(0) + End If Else strCurrDataType = "" End If