From 584c2bc8b40fcc772099b24364120d9271bdee10 Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Wed, 27 Nov 2024 13:34:57 +0300 Subject: [PATCH 01/35] updating_column_selection --- instat/static/InstatObject/R/data_object_R6.R | 57 ++++++++++++++++++- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index 394c50eff4..61b7d28d6c 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -921,8 +921,42 @@ DataSheet$set("public", "cor", function(x_col_names, y_col_name, use = "everythi } ) +DataSheet$set("public", "update_selection", function(new_values, column_selection_name = NULL) { + if(missing(new_values)) stop("new_values is required") + + # Find the column selection to update + if (is.null(column_selection_name)) { + stop("A column selection name must be provided to update the selection.") + } + + column_selection_obj <- private$column_selections[[column_selection_name]] + + if (is.null(column_selection_obj)) { + stop("No column selection found with the name: ", column_selection_name) + } + + # Update conditions in the column selection with new values + updated_conditions <- lapply(column_selection_obj$conditions, function(condition) { + # Check if the parameters exist and replace them with new values + if ("parameters" %in% names(condition)) { + condition$parameters$x <- new_values + } + return(condition) + }) + + # Update the column selection object with the new conditions + column_selection_obj$conditions <- updated_conditions + private$column_selections[[column_selection_name]] <- column_selection_obj + + # Optionally, mark data as changed + self$data_changed <- TRUE + + message("Column selection '", column_selection_name, "' updated successfully with new values.") +}) + + DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", new_col_name = "", label = "", type = "single", .fn, .cols = everything(), new_column_names_df, new_labels_df, ...) { - curr_data <- self$get_data_frame(use_current_filter = FALSE, use_column_selection = FALSE) + curr_data <- self$get_data_frame(use_current_filter = TRUE, use_column_selection = TRUE) # Save the current state to undo_history before making modifications self$save_state_to_undo_history() @@ -954,9 +988,16 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne purrr::map(.x = keys_to_delete, .f = ~self$remove_key(key_name = names(active_keys[.x]))) } } - if(self$column_selection_applied()) self$remove_current_column_selection() + #if(self$column_selection_applied()) self$remove_current_column_selection() # Need to use private$data here because changing names of data field names(private$data)[names(curr_data) == curr_col_name] <- new_col_name + + column_names <- self$get_column_names() + + # Replace NAs in column names (if any) + column_names[is.na(column_names)] <- new_col_name + self$update_selection(column_names, private$.current_column_selection$name) + self$append_to_variables_metadata(new_col_name, name_label, new_col_name) # TODO decide if we need to do these 2 lines self$append_to_changes(list(Renamed_col, curr_col_name, new_col_name)) @@ -975,8 +1016,18 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne curr_col_names <- names(private$data) curr_col_names[cols_changed_index] <- new_col_names if(any(duplicated(curr_col_names))) stop("Cannot rename columns. Column names must be unique.") - if(self$column_selection_applied()) self$remove_current_column_selection() + #if(self$column_selection_applied()) self$remove_current_column_selection() names(private$data)[cols_changed_index] <- new_col_names + + column_names <- self$get_column_names() + + # Replace NAs in column names (if any) + # column_names[is.na(column_names)] <- new_col_names + print(column_names) + print(new_col_names) + print(names(private$data)) + self$update_selection(column_names, private$.current_column_selection$name) + for (i in seq_along(cols_changed_index)) { self$append_to_variables_metadata(new_col_names[i], name_label, new_col_names[i]) } From 30dd7a65e6387f8f10e91aa5ec2538d5302efc33 Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Wed, 27 Nov 2024 15:01:38 +0300 Subject: [PATCH 02/35] minor bug fixes --- instat/static/InstatObject/R/data_object_R6.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index 61b7d28d6c..399c1c3ddd 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -956,7 +956,7 @@ DataSheet$set("public", "update_selection", function(new_values, column_selectio DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", new_col_name = "", label = "", type = "single", .fn, .cols = everything(), new_column_names_df, new_labels_df, ...) { - curr_data <- self$get_data_frame(use_current_filter = TRUE, use_column_selection = TRUE) + curr_data <- self$get_data_frame(use_current_filter = TRUE, use_column_selection = FALSE) # Save the current state to undo_history before making modifications self$save_state_to_undo_history() From 9f9c38acaf38068e0fb5618d7eef951bc3a44bce Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Wed, 27 Nov 2024 21:07:55 +0300 Subject: [PATCH 03/35] improve the rename of multiple column when fileter is applied --- instat/dlgName.vb | 21 ++++++++++++++++- instat/static/InstatObject/R/data_object_R6.R | 23 +++++++++++-------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/instat/dlgName.vb b/instat/dlgName.vb index 8d04924200..01aba12ffa 100644 --- a/instat/dlgName.vb +++ b/instat/dlgName.vb @@ -33,6 +33,7 @@ Public Class dlgName Private clsStartwithFunction, clsEndswithFunction, clsMatchesFunction, clsContainsFunction As New RFunction Private WithEvents grdCurrentWorkSheet As Worksheet Private dctRowsNewNameChanged As New Dictionary(Of Integer, String) + Private dctRowsCurrentName As New Dictionary(Of Integer, String) Private dctRowsNewLabelChanged As New Dictionary(Of Integer, String) Private dctNameRowsValues As New Dictionary(Of Integer, String) Private dctCaseOptions As New Dictionary(Of String, String) @@ -327,10 +328,14 @@ Public Class dlgName If e.Range.Rows > 1 Then For iRow As Integer = iStartRowIndex To grdCurrentWorkSheet.SelectionRange.EndRow Dim strNewData As String = ValidateRVariable(grdCurrentWorkSheet.GetCellData(row:=iRow, col:=iColIndex), iColIndex) + Dim strOldData As String = grdCurrentWorkSheet.GetCellData(row:=iRow, col:=0) + GetOldNames(iRow, strOldData) RenameColumns(strNewData, iRow, iColIndex) Next Else Dim strNewData As String = ValidateRVariable(grdCurrentWorkSheet.GetCellData(row:=e.Range.Row, col:=iColIndex), iColIndex) + Dim strOldData As String = grdCurrentWorkSheet.GetCellData(row:=e.Range.Row, col:=0) + GetOldNames(e.Range.Row, strOldData) RenameColumns(strNewData, iStartRowIndex, iColIndex) End If ValidateNamesFromDictionary(iColIndex) @@ -380,10 +385,22 @@ Public Class dlgName Private Sub grdCurrSheet_AfterCellEdit(sender As Object, e As CellAfterEditEventArgs) Handles grdCurrentWorkSheet.AfterCellEdit Dim iCol As Integer = e.Cell.Column Dim strNewData As String = ValidateRVariable(e.NewData, iCol) + + Dim strFirstColumnData As String = grdCurrentWorkSheet(e.Cell.Row, 0).ToString() + + GetOldNames(e.Cell.Row, strFirstColumnData) RenameColumns(strNewData, e.Cell.Row, iCol) ValidateNamesFromDictionary(iCol) End Sub + Private Sub GetOldNames(iRow As Integer, strOldName As String) + If Not dctRowsCurrentName.ContainsKey(iRow) Then + dctRowsCurrentName.Add(iRow, strOldName) + Else + dctRowsCurrentName(iRow) = strOldName + End If + End Sub + Private Sub GetVariables(strNewData As String, iRowIndex As Integer, iColIndex As Integer) If rdoMultiple.Checked Then If iColIndex = 1 Then @@ -391,7 +408,7 @@ Public Class dlgName AddChangedNewNameRows(iRowIndex, strNewData) clsNewColNameDataframeFunction.AddParameter("cols", GetValuesAsVector(dctRowsNewNameChanged), iPosition:=0) - clsNewColNameDataframeFunction.AddParameter("index", "c(" & String.Join(",", dctRowsNewNameChanged.Keys.ToArray) & ")", iPosition:=1) + clsNewColNameDataframeFunction.AddParameter("old_names", GetValuesAsVector(dctRowsCurrentName), iPosition:=1) clsDefaultRFunction.AddParameter("new_column_names_df", clsRFunctionParameter:=clsNewColNameDataframeFunction, iPosition:=8) Else clsNewColNameDataframeFunction.RemoveParameterByName("cols") @@ -652,6 +669,8 @@ Public Class dlgName Dim parsedValue As Boolean Dim strNewData As String = ValidateRVariable(e.Text, iCol) If Not strNewData.ToLower.Equals("t") AndAlso Not strNewData.ToLower.Equals("f") AndAlso Not IsNumeric(strNewData) AndAlso Not Boolean.TryParse(strNewData, parsedValue) Then + Dim strFirstColumnData As String = grdCurrentWorkSheet(e.Cell.Row, 0).ToString() + GetOldNames(e.Cell.Row, strFirstColumnData) RenameColumns(strNewData, e.Cell.Row, iCol) ValidateNamesFromDictionary(iCol) End If diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index 399c1c3ddd..70315c2580 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -956,7 +956,7 @@ DataSheet$set("public", "update_selection", function(new_values, column_selectio DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", new_col_name = "", label = "", type = "single", .fn, .cols = everything(), new_column_names_df, new_labels_df, ...) { - curr_data <- self$get_data_frame(use_current_filter = TRUE, use_column_selection = FALSE) + curr_data <- self$get_data_frame(use_current_filter = FALSE, use_column_selection = FALSE) # Save the current state to undo_history before making modifications self$save_state_to_undo_history() @@ -994,8 +994,12 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne column_names <- self$get_column_names() - # Replace NAs in column names (if any) - column_names[is.na(column_names)] <- new_col_name + if (any(is.na(column_names))) { + column_names[is.na(column_names)] <- new_col_name + } else { + column_names <- new_col_name + } + self$update_selection(column_names, private$.current_column_selection$name) self$append_to_variables_metadata(new_col_name, name_label, new_col_name) @@ -1012,7 +1016,7 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne } else if (type == "multiple") { if (!missing(new_column_names_df)) { new_col_names <- new_column_names_df[, 1] - cols_changed_index <- new_column_names_df[, 2] + cols_changed_index <- which(names(private$data) %in% new_column_names_df[, 2]) curr_col_names <- names(private$data) curr_col_names[cols_changed_index] <- new_col_names if(any(duplicated(curr_col_names))) stop("Cannot rename columns. Column names must be unique.") @@ -1021,11 +1025,12 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne column_names <- self$get_column_names() - # Replace NAs in column names (if any) - # column_names[is.na(column_names)] <- new_col_names - print(column_names) - print(new_col_names) - print(names(private$data)) + if (any(is.na(column_names))) { + column_names[is.na(column_names)] <- new_col_names + } else { + column_names <- new_col_names + } + self$update_selection(column_names, private$.current_column_selection$name) for (i in seq_along(cols_changed_index)) { From 35c653ae011df9315ae75424099f93fa31513cb0 Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Wed, 27 Nov 2024 21:26:41 +0300 Subject: [PATCH 04/35] fixed the renaming with when selection applied --- instat/static/InstatObject/R/data_object_R6.R | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index 70315c2580..bae307f3d8 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -1051,19 +1051,31 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne } else if (type == "rename_with") { if (missing(.fn)) stop(.fn, "is missing with no default.") curr_col_names <- names(curr_data) + column_names <- self$get_column_names() private$data <- curr_data |> dplyr::rename_with( .fn = .fn, .cols = {{ .cols }}, ... ) - if(self$column_selection_applied()) self$remove_current_column_selection() new_col_names <- names(private$data) if (!all(new_col_names %in% curr_col_names)) { new_col_names <- new_col_names[!(new_col_names %in% curr_col_names)] + + print(new_col_names) for (i in seq_along(new_col_names)) { self$append_to_variables_metadata(new_col_names[i], name_label, new_col_names[i]) } + + column_names <- self$get_column_names() + if (any(is.na(column_names))) { + column_names[is.na(column_names)] <- new_col_names + } else { + column_names <- new_col_names + } + + self$update_selection(column_names, private$.current_column_selection$name) + self$data_changed <- TRUE self$variables_metadata_changed <- TRUE } From 933921b42e493d85118a2a06edafd7c402d8c0af Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Thu, 28 Nov 2024 10:08:55 +0300 Subject: [PATCH 05/35] minor addition --- instat/dlgName.vb | 1 + 1 file changed, 1 insertion(+) diff --git a/instat/dlgName.vb b/instat/dlgName.vb index 7b69b5cafb..589d415d87 100644 --- a/instat/dlgName.vb +++ b/instat/dlgName.vb @@ -176,6 +176,7 @@ Public Class dlgName ucrSelectVariables.Reset() dctRowsNewNameChanged.Clear() dctRowsNewLabelChanged.Clear() + dctRowsCurrentName.Clear() bCurrentCell = False clsNewColNameDataframeFunction.SetRCommand("data.frame") From ee6dc92d7d44a6b83b02c9de2ba538b16791d4a5 Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Thu, 28 Nov 2024 10:32:01 +0300 Subject: [PATCH 06/35] retaining the status rename_with options after re-opening --- instat/dlgName.vb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/instat/dlgName.vb b/instat/dlgName.vb index 589d415d87..0f7ad48b76 100644 --- a/instat/dlgName.vb +++ b/instat/dlgName.vb @@ -95,11 +95,9 @@ Public Class dlgName ucrPnlCase.AddRadioButton(rdoAbbreviate, "abbreviate") ucrPnlCase.AddRadioButton(rdoReplace, "stringr::str_replace") - ucrPnlSelectData.SetParameter(New RParameter("data", 0)) - ucrPnlSelectData.AddRadioButton(rdoWholeDataFrame) - ucrPnlSelectData.AddRadioButton(rdoSelectedColumn) - ucrPnlSelectData.AddParameterValuesCondition(rdoWholeDataFrame, "checked", "whole") - ucrPnlSelectData.AddParameterValuesCondition(rdoSelectedColumn, "checked", "selected") + ucrPnlSelectData.SetParameter(New RParameter("checked", 1)) + ucrPnlSelectData.AddRadioButton(rdoWholeDataFrame, "whole") + ucrPnlSelectData.AddRadioButton(rdoSelectedColumn, "selected") ucrReceiverColumns.SetParameter(New RParameter(".cols", 6)) ucrReceiverColumns.Selector = ucrSelectVariables @@ -697,6 +695,7 @@ Public Class dlgName Case "Contains" clsDefaultRFunction.AddParameter(".cols", clsRFunctionParameter:=clsContainsFunction, iPosition:=3) End Select + Else clsDefaultRFunction.RemoveParameterByName("pattern") clsDefaultRFunction.RemoveParameterByName("replacement") From ae37c80ba2c6e1d8edf720b65f5334423aed4508 Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Mon, 2 Dec 2024 21:37:47 +0300 Subject: [PATCH 07/35] fixed developer error --- instat/dlgName.vb | 10 +++++++--- instat/dlgSelect.vb | 6 ++++++ instat/frmMain.vb | 4 ++++ instat/ucrDataView.vb | 4 ++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/instat/dlgName.vb b/instat/dlgName.vb index 0f7ad48b76..7c507648b7 100644 --- a/instat/dlgName.vb +++ b/instat/dlgName.vb @@ -95,9 +95,11 @@ Public Class dlgName ucrPnlCase.AddRadioButton(rdoAbbreviate, "abbreviate") ucrPnlCase.AddRadioButton(rdoReplace, "stringr::str_replace") - ucrPnlSelectData.SetParameter(New RParameter("checked", 1)) - ucrPnlSelectData.AddRadioButton(rdoWholeDataFrame, "whole") - ucrPnlSelectData.AddRadioButton(rdoSelectedColumn, "selected") + + ucrPnlSelectData.AddRadioButton(rdoWholeDataFrame) + ucrPnlSelectData.AddRadioButton(rdoSelectedColumn) + ucrPnlSelectData.AddParameterValuesCondition(rdoWholeDataFrame, "checked", "whole") + ucrPnlSelectData.AddParameterValuesCondition(rdoSelectedColumn, "checked", "selected") ucrReceiverColumns.SetParameter(New RParameter(".cols", 6)) ucrReceiverColumns.Selector = ucrSelectVariables @@ -592,7 +594,9 @@ Public Class dlgName rdoReplace.Visible = rdoWholeDataFrame.Checked If rdoWholeDataFrame.Checked Then ucrReceiverColumns.Visible = False + clsDummyFunction.AddParameter("checked", "whole", iPosition:=1) Else + clsDummyFunction.AddParameter("checked", "selected", iPosition:=1) ucrReceiverColumns.SetMeAsReceiver() If rdoReplace.Checked Then rdoMakeCleanNames.Checked = True diff --git a/instat/dlgSelect.vb b/instat/dlgSelect.vb index 2bc3630c75..9d9d2acc09 100644 --- a/instat/dlgSelect.vb +++ b/instat/dlgSelect.vb @@ -137,6 +137,12 @@ Public Class dlgSelect End Sub Private Sub cmdDefineNewSelect_Click(sender As Object, e As EventArgs) Handles cmdDefineNewSelect.Click + If frmMain.IsColumnSelectionApplied Then + Dim clsRemoveCurrentSelection As New RFunction + clsRemoveCurrentSelection.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$remove_current_column_selection") + clsRemoveCurrentSelection.AddParameter("data_name", Chr(34) & ucrSelectorForSelectColumns.strCurrentDataFrame & Chr(34)) + frmMain.clsRLink.RunScript(clsRemoveCurrentSelection.ToScript, strComment:="Remove current selection") + End If dlgSelectColumns.SetDefaultDataFrame(ucrSelectorForSelectColumns.ucrAvailableDataFrames.strCurrDataFrame) dlgSelectColumns.ShowDialog() ucrSelectorForSelectColumns.LoadList() diff --git a/instat/frmMain.vb b/instat/frmMain.vb index d5c70d0953..ae287e33ef 100644 --- a/instat/frmMain.vb +++ b/instat/frmMain.vb @@ -1724,6 +1724,10 @@ Public Class frmMain ucrDataViewer.UseColumnSelectionInDataView(bUseColumnSelecion) End Sub + Public Function IsColumnSelectionApplied() As Boolean + Return ucrDataViewer.IsColumnSelectionApplied + End Function + Public Sub SetCurrentDataFrame(strDataName As String) ucrDataViewer.SetCurrentDataFrame(strDataName) ucrColumnMeta.SetCurrentDataFrame(strDataName) diff --git a/instat/ucrDataView.vb b/instat/ucrDataView.vb index 109af059b4..53eb096ed7 100644 --- a/instat/ucrDataView.vb +++ b/instat/ucrDataView.vb @@ -466,6 +466,10 @@ Public Class ucrDataView End If End Sub + Public Function IsColumnSelectionApplied() As Boolean + Return GetCurrentDataFrameFocus().clsFilterOrColumnSelection.bColumnSelectionApplied + End Function + Private Function GetSelectedColumns() As List(Of clsColumnHeaderDisplay) Return _grid.GetSelectedColumns() End Function From eb95a5c7e65a39d74546507495c160563d0a3fc5 Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Tue, 3 Dec 2024 07:10:20 +0300 Subject: [PATCH 08/35] minor change in the rename function --- instat/static/InstatObject/R/data_object_R6.R | 4 ---- 1 file changed, 4 deletions(-) diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index bae307f3d8..efe70399d4 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -988,7 +988,6 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne purrr::map(.x = keys_to_delete, .f = ~self$remove_key(key_name = names(active_keys[.x]))) } } - #if(self$column_selection_applied()) self$remove_current_column_selection() # Need to use private$data here because changing names of data field names(private$data)[names(curr_data) == curr_col_name] <- new_col_name @@ -1020,7 +1019,6 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne curr_col_names <- names(private$data) curr_col_names[cols_changed_index] <- new_col_names if(any(duplicated(curr_col_names))) stop("Cannot rename columns. Column names must be unique.") - #if(self$column_selection_applied()) self$remove_current_column_selection() names(private$data)[cols_changed_index] <- new_col_names column_names <- self$get_column_names() @@ -1061,8 +1059,6 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne new_col_names <- names(private$data) if (!all(new_col_names %in% curr_col_names)) { new_col_names <- new_col_names[!(new_col_names %in% curr_col_names)] - - print(new_col_names) for (i in seq_along(new_col_names)) { self$append_to_variables_metadata(new_col_names[i], name_label, new_col_names[i]) } From c7e257d5e93ca69c2600f84fcc862a262a34c7d8 Mon Sep 17 00:00:00 2001 From: Fidel365 <107605960+Fidel365@users.noreply.github.com> Date: Mon, 13 Jan 2025 23:49:22 +0300 Subject: [PATCH 09/35] design changes --- .../RCommand/clsPrepareFunctionsForGrids.vb | 2 +- instat/ucrColumnMetadata.Designer.vb | 19 ++++--- instat/ucrColumnMetadata.vb | 6 --- instat/ucrDataFrameMetadata.Designer.vb | 52 +++++++++---------- instat/ucrDataFrameMetadata.vb | 6 ++- 5 files changed, 40 insertions(+), 45 deletions(-) diff --git a/instat/Model/RCommand/clsPrepareFunctionsForGrids.vb b/instat/Model/RCommand/clsPrepareFunctionsForGrids.vb index a55ccc8b2a..61c4d09ca6 100644 --- a/instat/Model/RCommand/clsPrepareFunctionsForGrids.vb +++ b/instat/Model/RCommand/clsPrepareFunctionsForGrids.vb @@ -184,7 +184,7 @@ Public Class clsPrepareFunctionsForGrids clsViewDataFrame.AddParameter("x", clsRFunctionParameter:=clsGetDataFrame) clsGetDataFrame.SetAssignTo(_strDataFrame) strTemp = clsViewDataFrame.ToScript(strScript) - _RLink.RunScript(strScript & strTemp, strComment:="Right click menu: View R Data Frame", bSeparateThread:=False) + _RLink.RunScript(strScript & strTemp, strComment:="Toolbar Option: View R Data Frame", bSeparateThread:=False) End Sub ''' ''' insert new rows diff --git a/instat/ucrColumnMetadata.Designer.vb b/instat/ucrColumnMetadata.Designer.vb index 23b0067bd9..301a3b4519 100644 --- a/instat/ucrColumnMetadata.Designer.vb +++ b/instat/ucrColumnMetadata.Designer.vb @@ -49,7 +49,6 @@ Partial Class ucrColumnMetadata Me.unhideSheet = New System.Windows.Forms.ToolStripMenuItem() Me.copySheet = New System.Windows.Forms.ToolStripMenuItem() Me.reorderSheet = New System.Windows.Forms.ToolStripMenuItem() - Me.viewSheet = New System.Windows.Forms.ToolStripMenuItem() Me.ToolStripSeparator4 = New System.Windows.Forms.ToolStripSeparator() Me.mnuHelp2 = New System.Windows.Forms.ToolStripMenuItem() Me.propertiesContextMenuStrip = New System.Windows.Forms.ContextMenuStrip(Me.components) @@ -82,6 +81,7 @@ Partial Class ucrColumnMetadata Me.columnContextMenuStrip = New System.Windows.Forms.ContextMenuStrip(Me.components) Me.ToolStripSeparator3 = New System.Windows.Forms.ToolStripSeparator() Me.mnuHelp1 = New System.Windows.Forms.ToolStripMenuItem() + Me.ToolStripSeparator5 = New System.Windows.Forms.ToolStripSeparator() Me.cellContextMenuStrip.SuspendLayout() Me.statusColumnMenu.SuspendLayout() Me.propertiesContextMenuStrip.SuspendLayout() @@ -105,9 +105,9 @@ Partial Class ucrColumnMetadata 'statusColumnMenu ' Me.statusColumnMenu.ImageScalingSize = New System.Drawing.Size(20, 20) - Me.statusColumnMenu.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.deleteDataFrame, Me.renameSheet, Me.mnuBottomAddComment, Me.hideSheet, Me.unhideSheet, Me.copySheet, Me.reorderSheet, Me.viewSheet, Me.ToolStripSeparator4, Me.mnuHelp2}) + Me.statusColumnMenu.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.renameSheet, Me.reorderSheet, Me.copySheet, Me.deleteDataFrame, Me.hideSheet, Me.unhideSheet, Me.ToolStripSeparator5, Me.mnuBottomAddComment, Me.ToolStripSeparator4, Me.mnuHelp2}) Me.statusColumnMenu.Name = "statusColumnMenu" - Me.statusColumnMenu.Size = New System.Drawing.Size(181, 230) + Me.statusColumnMenu.Size = New System.Drawing.Size(181, 214) ' 'deleteDataFrame ' @@ -151,12 +151,6 @@ Partial Class ucrColumnMetadata Me.reorderSheet.Size = New System.Drawing.Size(180, 22) Me.reorderSheet.Text = "Reorder..." ' - 'viewSheet - ' - Me.viewSheet.Name = "viewSheet" - Me.viewSheet.Size = New System.Drawing.Size(180, 22) - Me.viewSheet.Text = "View Data Frame" - ' 'ToolStripSeparator4 ' Me.ToolStripSeparator4.Name = "ToolStripSeparator4" @@ -373,6 +367,11 @@ Partial Class ucrColumnMetadata Me.mnuHelp1.Size = New System.Drawing.Size(214, 22) Me.mnuHelp1.Text = "Help" ' + 'ToolStripSeparator5 + ' + Me.ToolStripSeparator5.Name = "ToolStripSeparator5" + Me.ToolStripSeparator5.Size = New System.Drawing.Size(177, 6) + ' 'ucrColumnMetadata ' Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) @@ -403,7 +402,6 @@ Partial Class ucrColumnMetadata Friend WithEvents unhideSheet As ToolStripMenuItem Friend WithEvents copySheet As ToolStripMenuItem Friend WithEvents reorderSheet As ToolStripMenuItem - Friend WithEvents viewSheet As ToolStripMenuItem Friend WithEvents mnuBottomAddComment As ToolStripMenuItem Friend WithEvents ucrLinuxGrid As ucrColumnMetadataLinuxGrid Friend WithEvents ucrReoGrid As ucrColumnMetadataReoGrid @@ -433,4 +431,5 @@ Partial Class ucrColumnMetadata Friend WithEvents mnuHelp1 As ToolStripMenuItem Friend WithEvents ToolStripSeparator4 As ToolStripSeparator Friend WithEvents mnuHelp2 As ToolStripMenuItem + Friend WithEvents ToolStripSeparator5 As ToolStripSeparator End Class diff --git a/instat/ucrColumnMetadata.vb b/instat/ucrColumnMetadata.vb index 2d102ea97c..f7df8f6fc1 100644 --- a/instat/ucrColumnMetadata.vb +++ b/instat/ucrColumnMetadata.vb @@ -473,12 +473,6 @@ Public Class ucrColumnMetadata dlgCopyDataFrame.ShowDialog() End Sub - Private Sub viewSheet_Click(sender As Object, e As EventArgs) Handles viewSheet.Click - StartWait() - GetCurrentDataFrameFocus().clsPrepareFunctions.ViewDataFrame() - EndWait() - End Sub - Private Sub reorderSheet_Click(sender As Object, e As EventArgs) Handles reorderSheet.Click dlgReorderDataFrame.ShowDialog() End Sub diff --git a/instat/ucrDataFrameMetadata.Designer.vb b/instat/ucrDataFrameMetadata.Designer.vb index 94ceb188ed..371422d6c6 100644 --- a/instat/ucrDataFrameMetadata.Designer.vb +++ b/instat/ucrDataFrameMetadata.Designer.vb @@ -50,12 +50,12 @@ Partial Class ucrDataFrameMetadata Me.unhideSheet = New System.Windows.Forms.ToolStripMenuItem() Me.ToolStripSeparator11 = New System.Windows.Forms.ToolStripSeparator() Me.mnuAddComment = New System.Windows.Forms.ToolStripMenuItem() - Me.mnuViewHTML = New System.Windows.Forms.ToolStripMenuItem() - Me.viewSheet = New System.Windows.Forms.ToolStripMenuItem() Me.lblHeaderDataFrameMetaData = New System.Windows.Forms.Label() Me.tlpTableContainer = New System.Windows.Forms.TableLayoutPanel() Me.ucrLinuxGrid = New instat.ucrDataframeMetadataLinuxGrid() Me.ucrReoGrid = New instat.ucrDataframeMetadataReoGrid() + Me.HelpToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.ToolStripSeparator1 = New System.Windows.Forms.ToolStripSeparator() Me.cellContextMenuStrip.SuspendLayout() Me.rowRightClickMenu.SuspendLayout() Me.tlpTableContainer.SuspendLayout() @@ -77,71 +77,58 @@ Partial Class ucrDataFrameMetadata 'rowRightClickMenu ' Me.rowRightClickMenu.ImageScalingSize = New System.Drawing.Size(20, 20) - Me.rowRightClickMenu.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.renameSheet, Me.reorderSheet, Me.copySheet, Me.deleteDataFrame, Me.hideSheet, Me.unhideSheet, Me.ToolStripSeparator11, Me.mnuAddComment, Me.mnuViewHTML, Me.viewSheet}) + Me.rowRightClickMenu.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.renameSheet, Me.reorderSheet, Me.copySheet, Me.deleteDataFrame, Me.hideSheet, Me.unhideSheet, Me.ToolStripSeparator1, Me.mnuAddComment, Me.ToolStripSeparator11, Me.HelpToolStripMenuItem}) Me.rowRightClickMenu.Name = "statusColumnMenu" - Me.rowRightClickMenu.Size = New System.Drawing.Size(163, 208) + Me.rowRightClickMenu.Size = New System.Drawing.Size(181, 214) ' 'renameSheet ' Me.renameSheet.Name = "renameSheet" - Me.renameSheet.Size = New System.Drawing.Size(162, 22) + Me.renameSheet.Size = New System.Drawing.Size(180, 22) Me.renameSheet.Text = "Rename..." ' 'reorderSheet ' Me.reorderSheet.Enabled = False Me.reorderSheet.Name = "reorderSheet" - Me.reorderSheet.Size = New System.Drawing.Size(162, 22) + Me.reorderSheet.Size = New System.Drawing.Size(180, 22) Me.reorderSheet.Text = "Reorder..." ' 'copySheet ' Me.copySheet.Name = "copySheet" - Me.copySheet.Size = New System.Drawing.Size(162, 22) + Me.copySheet.Size = New System.Drawing.Size(180, 22) Me.copySheet.Text = "Copy..." ' 'deleteDataFrame ' Me.deleteDataFrame.Name = "deleteDataFrame" - Me.deleteDataFrame.Size = New System.Drawing.Size(162, 22) + Me.deleteDataFrame.Size = New System.Drawing.Size(180, 22) Me.deleteDataFrame.Text = "Delete..." ' 'hideSheet ' Me.hideSheet.Name = "hideSheet" - Me.hideSheet.Size = New System.Drawing.Size(162, 22) + Me.hideSheet.Size = New System.Drawing.Size(180, 22) Me.hideSheet.Text = "Hide" ' 'unhideSheet ' Me.unhideSheet.Name = "unhideSheet" - Me.unhideSheet.Size = New System.Drawing.Size(162, 22) + Me.unhideSheet.Size = New System.Drawing.Size(180, 22) Me.unhideSheet.Text = "Unhide..." ' 'ToolStripSeparator11 ' Me.ToolStripSeparator11.Name = "ToolStripSeparator11" - Me.ToolStripSeparator11.Size = New System.Drawing.Size(159, 6) + Me.ToolStripSeparator11.Size = New System.Drawing.Size(177, 6) ' 'mnuAddComment ' Me.mnuAddComment.Name = "mnuAddComment" - Me.mnuAddComment.Size = New System.Drawing.Size(162, 22) + Me.mnuAddComment.Size = New System.Drawing.Size(180, 22) Me.mnuAddComment.Text = "Add Comment..." ' - 'mnuViewHTML - ' - Me.mnuViewHTML.Enabled = False - Me.mnuViewHTML.Name = "mnuViewHTML" - Me.mnuViewHTML.Size = New System.Drawing.Size(162, 22) - Me.mnuViewHTML.Text = "View HTML" - ' - 'viewSheet - ' - Me.viewSheet.Name = "viewSheet" - Me.viewSheet.Size = New System.Drawing.Size(162, 22) - Me.viewSheet.Text = "View Data Frame" - ' 'lblHeaderDataFrameMetaData ' Me.lblHeaderDataFrameMetaData.BackColor = System.Drawing.Color.FromArgb(CType(CType(35, Byte), Integer), CType(CType(105, Byte), Integer), CType(CType(190, Byte), Integer)) @@ -192,6 +179,17 @@ Partial Class ucrDataFrameMetadata Me.ucrReoGrid.Size = New System.Drawing.Size(324, 381) Me.ucrReoGrid.TabIndex = 9 ' + 'HelpToolStripMenuItem + ' + Me.HelpToolStripMenuItem.Name = "HelpToolStripMenuItem" + Me.HelpToolStripMenuItem.Size = New System.Drawing.Size(180, 22) + Me.HelpToolStripMenuItem.Text = "Help" + ' + 'ToolStripSeparator1 + ' + Me.ToolStripSeparator1.Name = "ToolStripSeparator1" + Me.ToolStripSeparator1.Size = New System.Drawing.Size(177, 6) + ' 'ucrDataFrameMetadata ' Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) @@ -217,10 +215,10 @@ Partial Class ucrDataFrameMetadata Friend WithEvents unhideSheet As ToolStripMenuItem Friend WithEvents copySheet As ToolStripMenuItem Friend WithEvents reorderSheet As ToolStripMenuItem - Friend WithEvents viewSheet As ToolStripMenuItem Friend WithEvents mnuAddComment As ToolStripMenuItem Friend WithEvents ucrLinuxGrid As ucrDataframeMetadataLinuxGrid Friend WithEvents ucrReoGrid As ucrDataframeMetadataReoGrid - Friend WithEvents mnuViewHTML As ToolStripMenuItem Friend WithEvents ToolStripSeparator11 As ToolStripSeparator + Friend WithEvents ToolStripSeparator1 As ToolStripSeparator + Friend WithEvents HelpToolStripMenuItem As ToolStripMenuItem End Class diff --git a/instat/ucrDataFrameMetadata.vb b/instat/ucrDataFrameMetadata.vb index 821ff41308..a317bb685d 100644 --- a/instat/ucrDataFrameMetadata.vb +++ b/instat/ucrDataFrameMetadata.vb @@ -200,7 +200,7 @@ Public Class ucrDataFrameMetadata dlgCopyDataFrame.ShowDialog() End Sub - Private Sub viewSheet_Click(sender As Object, e As EventArgs) Handles viewSheet.Click + Private Sub viewSheet_Click(sender As Object, e As EventArgs) Dim strScript As String = "" Dim strTemp As String clsGetDataFrame.AddParameter("data_name", Chr(34) & GetSelectedDataframeNameFromSelectedRow() & Chr(34), iPosition:=0) @@ -222,4 +222,8 @@ Public Class ucrDataFrameMetadata dlgAddComment.SetPosition(strDataFrame:=_grid.CurrentWorksheet.Name) dlgAddComment.ShowDialog() End Sub + + Private Sub HelpToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles HelpToolStripMenuItem.Click + Help.ShowHelp(Me, frmMain.strStaticPath & "\" & frmMain.strHelpFilePath, HelpNavigator.TopicId, "544") + End Sub End Class \ No newline at end of file From d994fa9fcbed6ba027a2bd98f0f3df3f7383a58b Mon Sep 17 00:00:00 2001 From: Sophie Malla Tatchum Date: Wed, 15 Jan 2025 08:55:41 +0100 Subject: [PATCH 10/35] Add the R viewer to the Describe > View Graph dialog --- instat/dlgViewGraph.Designer.vb | 90 +++++++++++++++------------------ instat/dlgViewGraph.vb | 6 +-- 2 files changed, 44 insertions(+), 52 deletions(-) diff --git a/instat/dlgViewGraph.Designer.vb b/instat/dlgViewGraph.Designer.vb index e92f9875b3..8b80ba15a1 100644 --- a/instat/dlgViewGraph.Designer.vb +++ b/instat/dlgViewGraph.Designer.vb @@ -39,15 +39,15 @@ Partial Class dlgViewGraph Private Sub InitializeComponent() Me.grpDisplayOptions = New System.Windows.Forms.GroupBox() + Me.rdoMaximised = New System.Windows.Forms.RadioButton() Me.rdoInteractiveView = New System.Windows.Forms.RadioButton() Me.rdoRViewer = New System.Windows.Forms.RadioButton() Me.rdoOutputWindow = New System.Windows.Forms.RadioButton() + Me.ucrPnlDisplayOptions = New instat.UcrPanel() Me.lblGraphtoUse = New System.Windows.Forms.Label() Me.ucrGraphReceiver = New instat.ucrReceiverSingle() - Me.ucrPnlDisplayOptions = New instat.UcrPanel() Me.ucrGraphsSelector = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrBase = New instat.ucrButtons() - Me.rdoMaximised = New System.Windows.Forms.RadioButton() Me.grpDisplayOptions.SuspendLayout() Me.SuspendLayout() ' @@ -58,22 +58,30 @@ Partial Class dlgViewGraph Me.grpDisplayOptions.Controls.Add(Me.rdoRViewer) Me.grpDisplayOptions.Controls.Add(Me.rdoOutputWindow) Me.grpDisplayOptions.Controls.Add(Me.ucrPnlDisplayOptions) - Me.grpDisplayOptions.Location = New System.Drawing.Point(369, 135) - Me.grpDisplayOptions.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.grpDisplayOptions.Location = New System.Drawing.Point(246, 90) Me.grpDisplayOptions.Name = "grpDisplayOptions" - Me.grpDisplayOptions.Padding = New System.Windows.Forms.Padding(4, 4, 4, 4) - Me.grpDisplayOptions.Size = New System.Drawing.Size(326, 186) + Me.grpDisplayOptions.Size = New System.Drawing.Size(217, 124) Me.grpDisplayOptions.TabIndex = 3 Me.grpDisplayOptions.TabStop = False Me.grpDisplayOptions.Text = "Display Options" ' + 'rdoMaximised + ' + Me.rdoMaximised.AutoSize = True + Me.rdoMaximised.Location = New System.Drawing.Point(9, 43) + Me.rdoMaximised.Name = "rdoMaximised" + Me.rdoMaximised.Size = New System.Drawing.Size(113, 17) + Me.rdoMaximised.TabIndex = 4 + Me.rdoMaximised.TabStop = True + Me.rdoMaximised.Text = "Maximised window" + Me.rdoMaximised.UseVisualStyleBackColor = True + ' 'rdoInteractiveView ' Me.rdoInteractiveView.AutoSize = True - Me.rdoInteractiveView.Location = New System.Drawing.Point(14, 98) - Me.rdoInteractiveView.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.rdoInteractiveView.Location = New System.Drawing.Point(9, 65) Me.rdoInteractiveView.Name = "rdoInteractiveView" - Me.rdoInteractiveView.Size = New System.Drawing.Size(203, 24) + Me.rdoInteractiveView.Size = New System.Drawing.Size(140, 17) Me.rdoInteractiveView.TabIndex = 1 Me.rdoInteractiveView.TabStop = True Me.rdoInteractiveView.Text = "Interactive viewer(Plotly)" @@ -82,10 +90,9 @@ Partial Class dlgViewGraph 'rdoRViewer ' Me.rdoRViewer.AutoSize = True - Me.rdoRViewer.Location = New System.Drawing.Point(10, 130) - Me.rdoRViewer.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.rdoRViewer.Location = New System.Drawing.Point(9, 87) Me.rdoRViewer.Name = "rdoRViewer" - Me.rdoRViewer.Size = New System.Drawing.Size(99, 24) + Me.rdoRViewer.Size = New System.Drawing.Size(68, 17) Me.rdoRViewer.TabIndex = 2 Me.rdoRViewer.TabStop = True Me.rdoRViewer.Text = "R-Viewer" @@ -94,22 +101,29 @@ Partial Class dlgViewGraph 'rdoOutputWindow ' Me.rdoOutputWindow.AutoSize = True - Me.rdoOutputWindow.Location = New System.Drawing.Point(14, 33) - Me.rdoOutputWindow.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.rdoOutputWindow.Location = New System.Drawing.Point(9, 22) Me.rdoOutputWindow.Name = "rdoOutputWindow" - Me.rdoOutputWindow.Size = New System.Drawing.Size(139, 24) + Me.rdoOutputWindow.Size = New System.Drawing.Size(96, 17) Me.rdoOutputWindow.TabIndex = 3 Me.rdoOutputWindow.TabStop = True Me.rdoOutputWindow.Text = "Output window" Me.rdoOutputWindow.UseVisualStyleBackColor = True ' + 'ucrPnlDisplayOptions + ' + Me.ucrPnlDisplayOptions.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrPnlDisplayOptions.Location = New System.Drawing.Point(6, 19) + Me.ucrPnlDisplayOptions.Margin = New System.Windows.Forms.Padding(6, 6, 6, 6) + Me.ucrPnlDisplayOptions.Name = "ucrPnlDisplayOptions" + Me.ucrPnlDisplayOptions.Size = New System.Drawing.Size(203, 99) + Me.ucrPnlDisplayOptions.TabIndex = 0 + ' 'lblGraphtoUse ' Me.lblGraphtoUse.AutoSize = True - Me.lblGraphtoUse.Location = New System.Drawing.Point(375, 68) - Me.lblGraphtoUse.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) + Me.lblGraphtoUse.Location = New System.Drawing.Point(250, 45) Me.lblGraphtoUse.Name = "lblGraphtoUse" - Me.lblGraphtoUse.Size = New System.Drawing.Size(114, 20) + Me.lblGraphtoUse.Size = New System.Drawing.Size(77, 13) Me.lblGraphtoUse.TabIndex = 1 Me.lblGraphtoUse.Text = "Graph to View:" ' @@ -117,71 +131,49 @@ Partial Class dlgViewGraph ' Me.ucrGraphReceiver.AutoSize = True Me.ucrGraphReceiver.frmParent = Me - Me.ucrGraphReceiver.Location = New System.Drawing.Point(375, 90) + Me.ucrGraphReceiver.Location = New System.Drawing.Point(250, 60) Me.ucrGraphReceiver.Margin = New System.Windows.Forms.Padding(0) Me.ucrGraphReceiver.Name = "ucrGraphReceiver" Me.ucrGraphReceiver.Selector = Nothing - Me.ucrGraphReceiver.Size = New System.Drawing.Size(180, 30) + Me.ucrGraphReceiver.Size = New System.Drawing.Size(120, 20) Me.ucrGraphReceiver.strNcFilePath = "" Me.ucrGraphReceiver.TabIndex = 2 Me.ucrGraphReceiver.ucrSelector = Nothing ' - 'ucrPnlDisplayOptions - ' - Me.ucrPnlDisplayOptions.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrPnlDisplayOptions.Location = New System.Drawing.Point(9, 28) - Me.ucrPnlDisplayOptions.Margin = New System.Windows.Forms.Padding(9) - Me.ucrPnlDisplayOptions.Name = "ucrPnlDisplayOptions" - Me.ucrPnlDisplayOptions.Size = New System.Drawing.Size(304, 148) - Me.ucrPnlDisplayOptions.TabIndex = 0 - ' 'ucrGraphsSelector ' Me.ucrGraphsSelector.AutoSize = True Me.ucrGraphsSelector.bDropUnusedFilterLevels = False Me.ucrGraphsSelector.bShowHiddenColumns = False Me.ucrGraphsSelector.bUseCurrentFilter = True - Me.ucrGraphsSelector.Location = New System.Drawing.Point(15, 15) + Me.ucrGraphsSelector.Location = New System.Drawing.Point(10, 10) Me.ucrGraphsSelector.Margin = New System.Windows.Forms.Padding(0) Me.ucrGraphsSelector.Name = "ucrGraphsSelector" - Me.ucrGraphsSelector.Size = New System.Drawing.Size(320, 274) + Me.ucrGraphsSelector.Size = New System.Drawing.Size(213, 183) Me.ucrGraphsSelector.TabIndex = 0 ' 'ucrBase ' Me.ucrBase.AutoSize = True Me.ucrBase.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrBase.Location = New System.Drawing.Point(15, 330) - Me.ucrBase.Margin = New System.Windows.Forms.Padding(6) + Me.ucrBase.Location = New System.Drawing.Point(10, 220) + Me.ucrBase.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) Me.ucrBase.Name = "ucrBase" - Me.ucrBase.Size = New System.Drawing.Size(611, 77) + Me.ucrBase.Size = New System.Drawing.Size(408, 52) Me.ucrBase.TabIndex = 4 ' - 'rdoMaximised - ' - Me.rdoMaximised.AutoSize = True - Me.rdoMaximised.Location = New System.Drawing.Point(14, 65) - Me.rdoMaximised.Margin = New System.Windows.Forms.Padding(4) - Me.rdoMaximised.Name = "rdoMaximised" - Me.rdoMaximised.Size = New System.Drawing.Size(164, 24) - Me.rdoMaximised.TabIndex = 4 - Me.rdoMaximised.TabStop = True - Me.rdoMaximised.Text = "Maximised window" - Me.rdoMaximised.UseVisualStyleBackColor = True - ' 'dlgViewGraph ' - Me.AutoScaleDimensions = New System.Drawing.SizeF(144.0!, 144.0!) + Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi Me.AutoSize = True - Me.ClientSize = New System.Drawing.Size(706, 414) + Me.ClientSize = New System.Drawing.Size(471, 276) Me.Controls.Add(Me.ucrGraphReceiver) Me.Controls.Add(Me.lblGraphtoUse) Me.Controls.Add(Me.grpDisplayOptions) Me.Controls.Add(Me.ucrGraphsSelector) Me.Controls.Add(Me.ucrBase) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow - Me.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "dlgViewGraph" diff --git a/instat/dlgViewGraph.vb b/instat/dlgViewGraph.vb index 4151d80d9c..02a4de0766 100644 --- a/instat/dlgViewGraph.vb +++ b/instat/dlgViewGraph.vb @@ -63,7 +63,6 @@ Public Class dlgViewGraph 'todo. Calling print() from this dialog doesn't work. investigate why 'temporarily disabled - rdoRViewer.Enabled = False End Sub Private Sub SetDefaults() @@ -125,8 +124,9 @@ Public Class dlgViewGraph clsGetObjectRFunction.AddParameter("as_file", strParameterValue:="FALSE", iPosition:=2) ucrBase.clsRsyntax.SetBaseRFunction(clsViewObjectRFunction) ElseIf rdoRViewer.Checked Then - 'clsViewObjectRFunction.AddParameter("object", clsRFunctionParameter:=clsGetObjectRFunction) - 'clsViewObjectRFunction.RemoveParameterByName("object_format") + clsGetObjectRFunction.AddParameter("as_file", strParameterValue:="FALSE", iPosition:=2) + clsViewObjectRFunction.AddParameter("object", clsRFunctionParameter:=clsGetObjectRFunction) + clsViewObjectRFunction.RemoveParameterByName("object_format") ucrBase.clsRsyntax.SetBaseRFunction(clsPrintRFunction) End If End Sub From fdcbb000aa010473b9a6172c27306dd94f0c3ddd Mon Sep 17 00:00:00 2001 From: Fidel365 <107605960+Fidel365@users.noreply.github.com> Date: Wed, 15 Jan 2025 13:16:09 +0300 Subject: [PATCH 11/35] code cleaning --- instat/ucrDataFrameMetadata.vb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/instat/ucrDataFrameMetadata.vb b/instat/ucrDataFrameMetadata.vb index a317bb685d..29d90deadf 100644 --- a/instat/ucrDataFrameMetadata.vb +++ b/instat/ucrDataFrameMetadata.vb @@ -200,16 +200,6 @@ Public Class ucrDataFrameMetadata dlgCopyDataFrame.ShowDialog() End Sub - Private Sub viewSheet_Click(sender As Object, e As EventArgs) - Dim strScript As String = "" - Dim strTemp As String - clsGetDataFrame.AddParameter("data_name", Chr(34) & GetSelectedDataframeNameFromSelectedRow() & Chr(34), iPosition:=0) - clsViewDataFrame.AddParameter("x", clsRFunctionParameter:=clsGetDataFrame, iPosition:=0) - clsGetDataFrame.SetAssignTo(GetSelectedDataframeNameFromSelectedRow) - strTemp = clsViewDataFrame.ToScript(strScript) - RunScriptFromDataFrameMetadata(strScript & strTemp, strComment:="Right click menu: View R Data Frame", bSeparateThread:=False) - End Sub - Private Sub reorderSheet_Click(sender As Object, e As EventArgs) Handles reorderSheet.Click dlgReorderDataFrame.ShowDialog() End Sub From eeff7933cb4632e441b62ae08a215799152e21a1 Mon Sep 17 00:00:00 2001 From: Sophie Malla Tatchum Date: Thu, 16 Jan 2025 10:01:18 +0100 Subject: [PATCH 12/35] Change made --- instat/dlgViewGraph.vb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/instat/dlgViewGraph.vb b/instat/dlgViewGraph.vb index 02a4de0766..e65281d40e 100644 --- a/instat/dlgViewGraph.vb +++ b/instat/dlgViewGraph.vb @@ -40,6 +40,7 @@ Public Class dlgViewGraph Private Sub InitialiseDialog() ucrBase.iHelpTopicID = 525 + ucrBase.clsRsyntax.bSeparateThread = False 'Selector ucrGraphsSelector.SetParameter(New RParameter("data_name", 0)) @@ -125,8 +126,8 @@ Public Class dlgViewGraph ucrBase.clsRsyntax.SetBaseRFunction(clsViewObjectRFunction) ElseIf rdoRViewer.Checked Then clsGetObjectRFunction.AddParameter("as_file", strParameterValue:="FALSE", iPosition:=2) - clsViewObjectRFunction.AddParameter("object", clsRFunctionParameter:=clsGetObjectRFunction) - clsViewObjectRFunction.RemoveParameterByName("object_format") + 'clsViewObjectRFunction.AddParameter("object", clsRFunctionParameter:=clsGetObjectRFunction) + 'clsViewObjectRFunction.RemoveParameterByName("object_format") ucrBase.clsRsyntax.SetBaseRFunction(clsPrintRFunction) End If End Sub From 3e8b141ad5df82d22a49bcffca82e65166014f53 Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Thu, 16 Jan 2025 12:44:58 +0300 Subject: [PATCH 13/35] Update inno_install_script_64bit.iss --- inno_install_script_64bit.iss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inno_install_script_64bit.iss b/inno_install_script_64bit.iss index c2354f865a..8499603c09 100644 --- a/inno_install_script_64bit.iss +++ b/inno_install_script_64bit.iss @@ -7,8 +7,8 @@ ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) AppVersion= {#GetStringFileInfo("instat\bin\x64\Release\instat.exe", "FileVersion")} AppId={{5455FC1A-85BE-4679-B600-8A1A4FC3CDD9-{#SetupSetting("AppVersion")}} -AppName=R-Instat -AppVerName ={code:GetShortAppVersion|{#SetupSetting("AppVersion")}} +AppName=R-Instat {#SetupSetting("AppVersion")} +AppVerName =R-Instat {#SetupSetting("AppVersion")} AppPublisher=African Maths Initiative AppPublisherURL=http://r-instat.org/ From 6cb83570bf0e9917374a3ddf722e3521a0a3ff19 Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Fri, 17 Jan 2025 10:01:47 +0300 Subject: [PATCH 14/35] bug fix in levels/labels when filter is applied --- instat/static/InstatObject/R/data_object_R6.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index b123c0a54e..b3d93a5126 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -1545,7 +1545,7 @@ DataSheet$set("public", "get_data_frame_length", function(use_current_filter = F DataSheet$set("public", "get_factor_data_frame", function(col_name = "", include_levels = TRUE, include_NA_level = FALSE) { if(!(col_name %in% self$get_column_names())) stop(col_name, " is not a column name,") - col_data <- self$get_columns_from_data(col_name, use_current_filter = FALSE) + col_data <- self$get_columns_from_data(col_name, use_current_filter = TRUE) if(!(is.factor(col_data))) stop(col_name, " is not a factor column") counts <- data.frame(table(col_data)) From 3114fc166a87425ee89ac192d71df192e7d4b1b8 Mon Sep 17 00:00:00 2001 From: Sophie Malla Tatchum Date: Fri, 17 Jan 2025 11:19:44 +0100 Subject: [PATCH 15/35] minor change made --- instat/dlgViewGraph.vb | 2 -- 1 file changed, 2 deletions(-) diff --git a/instat/dlgViewGraph.vb b/instat/dlgViewGraph.vb index e65281d40e..151b125fda 100644 --- a/instat/dlgViewGraph.vb +++ b/instat/dlgViewGraph.vb @@ -126,8 +126,6 @@ Public Class dlgViewGraph ucrBase.clsRsyntax.SetBaseRFunction(clsViewObjectRFunction) ElseIf rdoRViewer.Checked Then clsGetObjectRFunction.AddParameter("as_file", strParameterValue:="FALSE", iPosition:=2) - 'clsViewObjectRFunction.AddParameter("object", clsRFunctionParameter:=clsGetObjectRFunction) - 'clsViewObjectRFunction.RemoveParameterByName("object_format") ucrBase.clsRsyntax.SetBaseRFunction(clsPrintRFunction) End If End Sub From aa5680b83a18dadc501eb7de77e957145e128142 Mon Sep 17 00:00:00 2001 From: Derrick Agorhom <76208189+derekagorhom@users.noreply.github.com> Date: Fri, 17 Jan 2025 13:41:40 +0100 Subject: [PATCH 16/35] Additional button in the Insert > Save Results Tab --- instat/dlgScript.Designer.vb | 751 +++++++++++++++++++---------------- instat/dlgScript.vb | 51 +++ 2 files changed, 467 insertions(+), 335 deletions(-) diff --git a/instat/dlgScript.Designer.vb b/instat/dlgScript.Designer.vb index ba37efac17..2e1e365de5 100644 --- a/instat/dlgScript.Designer.vb +++ b/instat/dlgScript.Designer.vb @@ -24,21 +24,38 @@ Partial Class dlgScript Private Sub InitializeComponent() Me.tbFeatures = New System.Windows.Forms.TabControl() Me.tbPageSaveData = New System.Windows.Forms.TabPage() + Me.ucrInputSaveRFile = New instat.ucrInputTextBox() Me.rdoFromRFile = New System.Windows.Forms.RadioButton() Me.rdoDataFrame = New System.Windows.Forms.RadioButton() + Me.ucrChkDisplayGraph = New instat.ucrCheck() + Me.ucrChkSaveDataFrameSingle = New instat.ucrCheck() + Me.ucrInputSaveDataFrame = New instat.ucrInputTextBox() Me.lblSaveObjectFormat = New System.Windows.Forms.Label() + Me.ucrCboSaveOutputObjectFormat = New instat.ucrInputComboBox() Me.lblSaveObjectType = New System.Windows.Forms.Label() + Me.ucrCboSaveOutputObjectType = New instat.ucrInputComboBox() Me.rdoSaveOutputObject = New System.Windows.Forms.RadioButton() Me.rdoSaveDataFrame = New System.Windows.Forms.RadioButton() Me.rdoSaveColumn = New System.Windows.Forms.RadioButton() + Me.ucrSaveObject = New instat.ucrSave() + Me.ucrDataFrameSaveOutputSelect = New instat.ucrDataFrame() + Me.ucrPnlSaveData = New instat.UcrPanel() + Me.ucrPnlSaveDataFrame = New instat.UcrPanel() Me.tbPageGetData = New System.Windows.Forms.TabPage() + Me.ucrReceiverGetOutputObject = New instat.ucrReceiverSingle() + Me.ucrReceiverGetColumns = New instat.ucrReceiverMultiple() Me.lblGetColumn = New System.Windows.Forms.Label() Me.lblGetObjectType = New System.Windows.Forms.Label() Me.rdoGetOutputObject = New System.Windows.Forms.RadioButton() Me.lblGetOutputObject = New System.Windows.Forms.Label() Me.rdoGetDataFrame = New System.Windows.Forms.RadioButton() Me.rdoGetColumn = New System.Windows.Forms.RadioButton() + Me.ucrDataFrameGetDF = New instat.ucrDataFrame() + Me.ucrCboGetOutputObjectType = New instat.ucrInputComboBox() + Me.ucrPnlGetData = New instat.UcrPanel() + Me.ucrSelectorGetObject = New instat.ucrSelectorByDataFrameAddRemove() Me.tbPageCommand = New System.Windows.Forms.TabPage() + Me.ucrChkWindow = New instat.ucrCheck() Me.rdoWindow = New System.Windows.Forms.RadioButton() Me.rdoListData = New System.Windows.Forms.RadioButton() Me.rdoViewData = New System.Windows.Forms.RadioButton() @@ -48,33 +65,6 @@ Partial Class dlgScript Me.rdoGgplotify = New System.Windows.Forms.RadioButton() Me.rdoCommandPackage = New System.Windows.Forms.RadioButton() Me.rdoCommandObject = New System.Windows.Forms.RadioButton() - Me.tbPageExamples = New System.Windows.Forms.TabPage() - Me.cmdHelp = New System.Windows.Forms.Button() - Me.rdoExampleData = New System.Windows.Forms.RadioButton() - Me.rdoExampleFunction = New System.Windows.Forms.RadioButton() - Me.lstExampleCollection = New System.Windows.Forms.ListView() - Me.clmDatasets = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) - Me.clmDesc = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) - Me.Label3 = New System.Windows.Forms.Label() - Me.lblPreview = New System.Windows.Forms.Label() - Me.txtScript = New System.Windows.Forms.TextBox() - Me.ucrInputSaveRFile = New instat.ucrInputTextBox() - Me.ucrChkDisplayGraph = New instat.ucrCheck() - Me.ucrChkSaveDataFrameSingle = New instat.ucrCheck() - Me.ucrInputSaveDataFrame = New instat.ucrInputTextBox() - Me.ucrCboSaveOutputObjectFormat = New instat.ucrInputComboBox() - Me.ucrCboSaveOutputObjectType = New instat.ucrInputComboBox() - Me.ucrSaveObject = New instat.ucrSave() - Me.ucrDataFrameSaveOutputSelect = New instat.ucrDataFrame() - Me.ucrPnlSaveData = New instat.UcrPanel() - Me.ucrPnlSaveDataFrame = New instat.UcrPanel() - Me.ucrReceiverGetOutputObject = New instat.ucrReceiverSingle() - Me.ucrReceiverGetColumns = New instat.ucrReceiverMultiple() - Me.ucrDataFrameGetDF = New instat.ucrDataFrame() - Me.ucrCboGetOutputObjectType = New instat.ucrInputComboBox() - Me.ucrPnlGetData = New instat.UcrPanel() - Me.ucrSelectorGetObject = New instat.ucrSelectorByDataFrameAddRemove() - Me.ucrChkWindow = New instat.ucrCheck() Me.ucrChkInto = New instat.ucrCheck() Me.ucrInputSaveData = New instat.ucrInputTextBox() Me.ucrCboCommandDataPackage = New instat.ucrInputComboBox() @@ -86,9 +76,25 @@ Partial Class dlgScript Me.ucrInputRemoveObjects = New instat.ucrInputTextBox() Me.ucrCboCommandPackage = New instat.ucrInputComboBox() Me.ucrPnlCommands = New instat.UcrPanel() + Me.tbPageExamples = New System.Windows.Forms.TabPage() + Me.cmdHelp = New System.Windows.Forms.Button() + Me.rdoExampleData = New System.Windows.Forms.RadioButton() + Me.rdoExampleFunction = New System.Windows.Forms.RadioButton() Me.ucrPnlExample = New instat.UcrPanel() + Me.lstExampleCollection = New System.Windows.Forms.ListView() + Me.clmDatasets = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.clmDesc = CType(New System.Windows.Forms.ColumnHeader(), System.Windows.Forms.ColumnHeader) + Me.Label3 = New System.Windows.Forms.Label() Me.ucrCboExamplePackages = New instat.ucrInputComboBox() + Me.lblPreview = New System.Windows.Forms.Label() + Me.txtScript = New System.Windows.Forms.TextBox() Me.ucrBase = New instat.ucrButtons() + Me.rdoVariable = New System.Windows.Forms.RadioButton() + Me.ucrInputSaveColumn = New instat.ucrInputTextBox() + Me.ucrInputDataframeColumn = New instat.ucrInputTextBox() + Me.lblSaveColumn = New System.Windows.Forms.Label() + Me.lblSaveDataFrame = New System.Windows.Forms.Label() + Me.lblSaveText = New System.Windows.Forms.Label() Me.tbFeatures.SuspendLayout() Me.tbPageSaveData.SuspendLayout() Me.tbPageGetData.SuspendLayout() @@ -110,6 +116,12 @@ Partial Class dlgScript ' 'tbPageSaveData ' + Me.tbPageSaveData.Controls.Add(Me.lblSaveText) + Me.tbPageSaveData.Controls.Add(Me.lblSaveDataFrame) + Me.tbPageSaveData.Controls.Add(Me.lblSaveColumn) + Me.tbPageSaveData.Controls.Add(Me.ucrInputDataframeColumn) + Me.tbPageSaveData.Controls.Add(Me.ucrInputSaveColumn) + Me.tbPageSaveData.Controls.Add(Me.rdoVariable) Me.tbPageSaveData.Controls.Add(Me.ucrInputSaveRFile) Me.tbPageSaveData.Controls.Add(Me.rdoFromRFile) Me.tbPageSaveData.Controls.Add(Me.rdoDataFrame) @@ -134,10 +146,22 @@ Partial Class dlgScript Me.tbPageSaveData.Text = "Save Data" Me.tbPageSaveData.UseVisualStyleBackColor = True ' + 'ucrInputSaveRFile + ' + Me.ucrInputSaveRFile.AddQuotesIfUnrecognised = True + Me.ucrInputSaveRFile.AutoSize = True + Me.ucrInputSaveRFile.IsMultiline = False + Me.ucrInputSaveRFile.IsReadOnly = False + Me.ucrInputSaveRFile.Location = New System.Drawing.Point(247, 137) + Me.ucrInputSaveRFile.Margin = New System.Windows.Forms.Padding(9) + Me.ucrInputSaveRFile.Name = "ucrInputSaveRFile" + Me.ucrInputSaveRFile.Size = New System.Drawing.Size(145, 21) + Me.ucrInputSaveRFile.TabIndex = 64 + ' 'rdoFromRFile ' Me.rdoFromRFile.AutoSize = True - Me.rdoFromRFile.Location = New System.Drawing.Point(83, 125) + Me.rdoFromRFile.Location = New System.Drawing.Point(238, 114) Me.rdoFromRFile.Margin = New System.Windows.Forms.Padding(2) Me.rdoFromRFile.Name = "rdoFromRFile" Me.rdoFromRFile.Size = New System.Drawing.Size(81, 17) @@ -149,15 +173,45 @@ Partial Class dlgScript 'rdoDataFrame ' Me.rdoDataFrame.AutoSize = True - Me.rdoDataFrame.Location = New System.Drawing.Point(83, 48) + Me.rdoDataFrame.Location = New System.Drawing.Point(48, 114) Me.rdoDataFrame.Margin = New System.Windows.Forms.Padding(2) Me.rdoDataFrame.Name = "rdoDataFrame" - Me.rdoDataFrame.Size = New System.Drawing.Size(109, 17) + Me.rdoDataFrame.Size = New System.Drawing.Size(104, 17) Me.rdoDataFrame.TabIndex = 62 Me.rdoDataFrame.TabStop = True - Me.rdoDataFrame.Text = "From Data Frame:" + Me.rdoDataFrame.Text = "Into Data Frame:" Me.rdoDataFrame.UseVisualStyleBackColor = True ' + 'ucrChkDisplayGraph + ' + Me.ucrChkDisplayGraph.AutoSize = True + Me.ucrChkDisplayGraph.Checked = False + Me.ucrChkDisplayGraph.Location = New System.Drawing.Point(88, 217) + Me.ucrChkDisplayGraph.Name = "ucrChkDisplayGraph" + Me.ucrChkDisplayGraph.Size = New System.Drawing.Size(113, 23) + Me.ucrChkDisplayGraph.TabIndex = 60 + ' + 'ucrChkSaveDataFrameSingle + ' + Me.ucrChkSaveDataFrameSingle.AutoSize = True + Me.ucrChkSaveDataFrameSingle.Checked = False + Me.ucrChkSaveDataFrameSingle.Location = New System.Drawing.Point(56, 167) + Me.ucrChkSaveDataFrameSingle.Name = "ucrChkSaveDataFrameSingle" + Me.ucrChkSaveDataFrameSingle.Size = New System.Drawing.Size(146, 23) + Me.ucrChkSaveDataFrameSingle.TabIndex = 59 + ' + 'ucrInputSaveDataFrame + ' + Me.ucrInputSaveDataFrame.AddQuotesIfUnrecognised = True + Me.ucrInputSaveDataFrame.AutoSize = True + Me.ucrInputSaveDataFrame.IsMultiline = False + Me.ucrInputSaveDataFrame.IsReadOnly = False + Me.ucrInputSaveDataFrame.Location = New System.Drawing.Point(57, 136) + Me.ucrInputSaveDataFrame.Margin = New System.Windows.Forms.Padding(9) + Me.ucrInputSaveDataFrame.Name = "ucrInputSaveDataFrame" + Me.ucrInputSaveDataFrame.Size = New System.Drawing.Size(145, 21) + Me.ucrInputSaveDataFrame.TabIndex = 57 + ' 'lblSaveObjectFormat ' Me.lblSaveObjectFormat.AutoSize = True @@ -167,6 +221,18 @@ Partial Class dlgScript Me.lblSaveObjectFormat.TabIndex = 56 Me.lblSaveObjectFormat.Text = "Format:" ' + 'ucrCboSaveOutputObjectFormat + ' + Me.ucrCboSaveOutputObjectFormat.AddQuotesIfUnrecognised = True + Me.ucrCboSaveOutputObjectFormat.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrCboSaveOutputObjectFormat.GetSetSelectedIndex = -1 + Me.ucrCboSaveOutputObjectFormat.IsReadOnly = False + Me.ucrCboSaveOutputObjectFormat.Location = New System.Drawing.Point(88, 160) + Me.ucrCboSaveOutputObjectFormat.Margin = New System.Windows.Forms.Padding(9) + Me.ucrCboSaveOutputObjectFormat.Name = "ucrCboSaveOutputObjectFormat" + Me.ucrCboSaveOutputObjectFormat.Size = New System.Drawing.Size(141, 21) + Me.ucrCboSaveOutputObjectFormat.TabIndex = 55 + ' 'lblSaveObjectType ' Me.lblSaveObjectType.AutoSize = True @@ -176,6 +242,18 @@ Partial Class dlgScript Me.lblSaveObjectType.TabIndex = 54 Me.lblSaveObjectType.Text = "Type:" ' + 'ucrCboSaveOutputObjectType + ' + Me.ucrCboSaveOutputObjectType.AddQuotesIfUnrecognised = True + Me.ucrCboSaveOutputObjectType.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrCboSaveOutputObjectType.GetSetSelectedIndex = -1 + Me.ucrCboSaveOutputObjectType.IsReadOnly = False + Me.ucrCboSaveOutputObjectType.Location = New System.Drawing.Point(87, 116) + Me.ucrCboSaveOutputObjectType.Margin = New System.Windows.Forms.Padding(9) + Me.ucrCboSaveOutputObjectType.Name = "ucrCboSaveOutputObjectType" + Me.ucrCboSaveOutputObjectType.Size = New System.Drawing.Size(144, 21) + Me.ucrCboSaveOutputObjectType.TabIndex = 53 + ' 'rdoSaveOutputObject ' Me.rdoSaveOutputObject.Appearance = System.Windows.Forms.Appearance.Button @@ -227,6 +305,44 @@ Partial Class dlgScript Me.rdoSaveColumn.TextAlign = System.Drawing.ContentAlignment.MiddleCenter Me.rdoSaveColumn.UseVisualStyleBackColor = True ' + 'ucrSaveObject + ' + Me.ucrSaveObject.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrSaveObject.Location = New System.Drawing.Point(88, 193) + Me.ucrSaveObject.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) + Me.ucrSaveObject.Name = "ucrSaveObject" + Me.ucrSaveObject.Size = New System.Drawing.Size(258, 22) + Me.ucrSaveObject.TabIndex = 35 + ' + 'ucrDataFrameSaveOutputSelect + ' + Me.ucrDataFrameSaveOutputSelect.AutoSize = True + Me.ucrDataFrameSaveOutputSelect.bDropUnusedFilterLevels = False + Me.ucrDataFrameSaveOutputSelect.bUseCurrentFilter = True + Me.ucrDataFrameSaveOutputSelect.Location = New System.Drawing.Point(86, 54) + Me.ucrDataFrameSaveOutputSelect.Margin = New System.Windows.Forms.Padding(0) + Me.ucrDataFrameSaveOutputSelect.Name = "ucrDataFrameSaveOutputSelect" + Me.ucrDataFrameSaveOutputSelect.Size = New System.Drawing.Size(224, 59) + Me.ucrDataFrameSaveOutputSelect.TabIndex = 29 + ' + 'ucrPnlSaveData + ' + Me.ucrPnlSaveData.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrPnlSaveData.Location = New System.Drawing.Point(13, 12) + Me.ucrPnlSaveData.Margin = New System.Windows.Forms.Padding(6) + Me.ucrPnlSaveData.Name = "ucrPnlSaveData" + Me.ucrPnlSaveData.Size = New System.Drawing.Size(402, 36) + Me.ucrPnlSaveData.TabIndex = 47 + ' + 'ucrPnlSaveDataFrame + ' + Me.ucrPnlSaveDataFrame.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrPnlSaveDataFrame.Location = New System.Drawing.Point(5, 48) + Me.ucrPnlSaveDataFrame.Margin = New System.Windows.Forms.Padding(6) + Me.ucrPnlSaveDataFrame.Name = "ucrPnlSaveDataFrame" + Me.ucrPnlSaveDataFrame.Size = New System.Drawing.Size(429, 134) + Me.ucrPnlSaveDataFrame.TabIndex = 65 + ' 'tbPageGetData ' Me.tbPageGetData.Controls.Add(Me.ucrReceiverGetOutputObject) @@ -249,6 +365,32 @@ Partial Class dlgScript Me.tbPageGetData.Text = "Get Data" Me.tbPageGetData.UseVisualStyleBackColor = True ' + 'ucrReceiverGetOutputObject + ' + Me.ucrReceiverGetOutputObject.AutoSize = True + Me.ucrReceiverGetOutputObject.frmParent = Nothing + Me.ucrReceiverGetOutputObject.Location = New System.Drawing.Point(240, 117) + Me.ucrReceiverGetOutputObject.Margin = New System.Windows.Forms.Padding(0) + Me.ucrReceiverGetOutputObject.Name = "ucrReceiverGetOutputObject" + Me.ucrReceiverGetOutputObject.Selector = Nothing + Me.ucrReceiverGetOutputObject.Size = New System.Drawing.Size(138, 20) + Me.ucrReceiverGetOutputObject.strNcFilePath = "" + Me.ucrReceiverGetOutputObject.TabIndex = 27 + Me.ucrReceiverGetOutputObject.ucrSelector = Nothing + ' + 'ucrReceiverGetColumns + ' + Me.ucrReceiverGetColumns.AutoSize = True + Me.ucrReceiverGetColumns.frmParent = Nothing + Me.ucrReceiverGetColumns.Location = New System.Drawing.Point(243, 104) + Me.ucrReceiverGetColumns.Margin = New System.Windows.Forms.Padding(0) + Me.ucrReceiverGetColumns.Name = "ucrReceiverGetColumns" + Me.ucrReceiverGetColumns.Selector = Nothing + Me.ucrReceiverGetColumns.Size = New System.Drawing.Size(137, 105) + Me.ucrReceiverGetColumns.strNcFilePath = "" + Me.ucrReceiverGetColumns.TabIndex = 49 + Me.ucrReceiverGetColumns.ucrSelector = Nothing + ' 'lblGetColumn ' Me.lblGetColumn.AutoSize = True @@ -329,6 +471,50 @@ Partial Class dlgScript Me.rdoGetColumn.TextAlign = System.Drawing.ContentAlignment.MiddleCenter Me.rdoGetColumn.UseVisualStyleBackColor = True ' + 'ucrDataFrameGetDF + ' + Me.ucrDataFrameGetDF.AutoSize = True + Me.ucrDataFrameGetDF.bDropUnusedFilterLevels = False + Me.ucrDataFrameGetDF.bUseCurrentFilter = True + Me.ucrDataFrameGetDF.Location = New System.Drawing.Point(81, 55) + Me.ucrDataFrameGetDF.Margin = New System.Windows.Forms.Padding(0) + Me.ucrDataFrameGetDF.Name = "ucrDataFrameGetDF" + Me.ucrDataFrameGetDF.Size = New System.Drawing.Size(224, 59) + Me.ucrDataFrameGetDF.TabIndex = 31 + ' + 'ucrCboGetOutputObjectType + ' + Me.ucrCboGetOutputObjectType.AddQuotesIfUnrecognised = True + Me.ucrCboGetOutputObjectType.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrCboGetOutputObjectType.GetSetSelectedIndex = -1 + Me.ucrCboGetOutputObjectType.IsReadOnly = False + Me.ucrCboGetOutputObjectType.Location = New System.Drawing.Point(241, 72) + Me.ucrCboGetOutputObjectType.Margin = New System.Windows.Forms.Padding(9) + Me.ucrCboGetOutputObjectType.Name = "ucrCboGetOutputObjectType" + Me.ucrCboGetOutputObjectType.Size = New System.Drawing.Size(137, 21) + Me.ucrCboGetOutputObjectType.TabIndex = 47 + ' + 'ucrPnlGetData + ' + Me.ucrPnlGetData.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink + Me.ucrPnlGetData.Location = New System.Drawing.Point(5, 10) + Me.ucrPnlGetData.Margin = New System.Windows.Forms.Padding(6) + Me.ucrPnlGetData.Name = "ucrPnlGetData" + Me.ucrPnlGetData.Size = New System.Drawing.Size(402, 36) + Me.ucrPnlGetData.TabIndex = 42 + ' + 'ucrSelectorGetObject + ' + Me.ucrSelectorGetObject.AutoSize = True + Me.ucrSelectorGetObject.bDropUnusedFilterLevels = False + Me.ucrSelectorGetObject.bShowHiddenColumns = False + Me.ucrSelectorGetObject.bUseCurrentFilter = True + Me.ucrSelectorGetObject.Location = New System.Drawing.Point(9, 52) + Me.ucrSelectorGetObject.Margin = New System.Windows.Forms.Padding(0) + Me.ucrSelectorGetObject.Name = "ucrSelectorGetObject" + Me.ucrSelectorGetObject.Size = New System.Drawing.Size(320, 274) + Me.ucrSelectorGetObject.TabIndex = 34 + ' 'tbPageCommand ' Me.tbPageCommand.Controls.Add(Me.ucrChkWindow) @@ -359,6 +545,15 @@ Partial Class dlgScript Me.tbPageCommand.Text = "Commands" Me.tbPageCommand.UseVisualStyleBackColor = True ' + 'ucrChkWindow + ' + Me.ucrChkWindow.AutoSize = True + Me.ucrChkWindow.Checked = False + Me.ucrChkWindow.Location = New System.Drawing.Point(233, 94) + Me.ucrChkWindow.Name = "ucrChkWindow" + Me.ucrChkWindow.Size = New System.Drawing.Size(126, 23) + Me.ucrChkWindow.TabIndex = 67 + ' 'rdoWindow ' Me.rdoWindow.AutoSize = True @@ -461,311 +656,14 @@ Partial Class dlgScript Me.rdoCommandObject.Text = "Remove Object(s):" Me.rdoCommandObject.UseVisualStyleBackColor = True ' - 'tbPageExamples + 'ucrChkInto ' - Me.tbPageExamples.Controls.Add(Me.cmdHelp) - Me.tbPageExamples.Controls.Add(Me.rdoExampleData) - Me.tbPageExamples.Controls.Add(Me.rdoExampleFunction) - Me.tbPageExamples.Controls.Add(Me.ucrPnlExample) - Me.tbPageExamples.Controls.Add(Me.lstExampleCollection) - Me.tbPageExamples.Controls.Add(Me.Label3) - Me.tbPageExamples.Controls.Add(Me.ucrCboExamplePackages) - Me.tbPageExamples.Location = New System.Drawing.Point(4, 22) - Me.tbPageExamples.Name = "tbPageExamples" - Me.tbPageExamples.Size = New System.Drawing.Size(438, 245) - Me.tbPageExamples.TabIndex = 4 - Me.tbPageExamples.Text = "Library" - Me.tbPageExamples.UseVisualStyleBackColor = True - ' - 'cmdHelp - ' - Me.cmdHelp.Location = New System.Drawing.Point(361, 4) - Me.cmdHelp.Name = "cmdHelp" - Me.cmdHelp.Size = New System.Drawing.Size(75, 23) - Me.cmdHelp.TabIndex = 61 - Me.cmdHelp.Text = "R Help" - Me.cmdHelp.UseVisualStyleBackColor = True - ' - 'rdoExampleData - ' - Me.rdoExampleData.Appearance = System.Windows.Forms.Appearance.Button - Me.rdoExampleData.FlatAppearance.BorderColor = System.Drawing.SystemColors.ActiveCaption - Me.rdoExampleData.FlatAppearance.BorderSize = 2 - Me.rdoExampleData.FlatAppearance.CheckedBackColor = System.Drawing.SystemColors.ActiveCaption - Me.rdoExampleData.FlatStyle = System.Windows.Forms.FlatStyle.Flat - Me.rdoExampleData.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.rdoExampleData.Location = New System.Drawing.Point(14, 54) - Me.rdoExampleData.Name = "rdoExampleData" - Me.rdoExampleData.Size = New System.Drawing.Size(80, 30) - Me.rdoExampleData.TabIndex = 57 - Me.rdoExampleData.TabStop = True - Me.rdoExampleData.Text = "Data" - Me.rdoExampleData.TextAlign = System.Drawing.ContentAlignment.MiddleCenter - Me.rdoExampleData.UseVisualStyleBackColor = True - ' - 'rdoExampleFunction - ' - Me.rdoExampleFunction.Appearance = System.Windows.Forms.Appearance.Button - Me.rdoExampleFunction.FlatAppearance.BorderColor = System.Drawing.SystemColors.ActiveCaption - Me.rdoExampleFunction.FlatAppearance.BorderSize = 2 - Me.rdoExampleFunction.FlatAppearance.CheckedBackColor = System.Drawing.SystemColors.ActiveCaption - Me.rdoExampleFunction.FlatStyle = System.Windows.Forms.FlatStyle.Flat - Me.rdoExampleFunction.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.rdoExampleFunction.Location = New System.Drawing.Point(92, 54) - Me.rdoExampleFunction.Name = "rdoExampleFunction" - Me.rdoExampleFunction.Size = New System.Drawing.Size(80, 30) - Me.rdoExampleFunction.TabIndex = 58 - Me.rdoExampleFunction.TabStop = True - Me.rdoExampleFunction.Text = "Function" - Me.rdoExampleFunction.TextAlign = System.Drawing.ContentAlignment.MiddleCenter - Me.rdoExampleFunction.UseVisualStyleBackColor = True - ' - 'lstExampleCollection - ' - Me.lstExampleCollection.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.clmDatasets, Me.clmDesc}) - Me.lstExampleCollection.FullRowSelect = True - Me.lstExampleCollection.HideSelection = False - Me.lstExampleCollection.Location = New System.Drawing.Point(3, 93) - Me.lstExampleCollection.MultiSelect = False - Me.lstExampleCollection.Name = "lstExampleCollection" - Me.lstExampleCollection.ShowGroups = False - Me.lstExampleCollection.ShowItemToolTips = True - Me.lstExampleCollection.Size = New System.Drawing.Size(415, 146) - Me.lstExampleCollection.Sorting = System.Windows.Forms.SortOrder.Ascending - Me.lstExampleCollection.TabIndex = 53 - Me.lstExampleCollection.UseCompatibleStateImageBehavior = False - Me.lstExampleCollection.View = System.Windows.Forms.View.Details - ' - 'clmDatasets - ' - Me.clmDatasets.Text = "Data" - Me.clmDatasets.Width = 142 - ' - 'clmDesc - ' - Me.clmDesc.Text = "Description" - Me.clmDesc.Width = 266 - ' - 'Label3 - ' - Me.Label3.AutoSize = True - Me.Label3.Location = New System.Drawing.Point(13, 5) - Me.Label3.Margin = New System.Windows.Forms.Padding(2, 0, 2, 0) - Me.Label3.Name = "Label3" - Me.Label3.Size = New System.Drawing.Size(50, 13) - Me.Label3.TabIndex = 52 - Me.Label3.Text = "Package" - ' - 'lblPreview - ' - Me.lblPreview.AutoSize = True - Me.lblPreview.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.lblPreview.Location = New System.Drawing.Point(9, 281) - Me.lblPreview.Name = "lblPreview" - Me.lblPreview.Size = New System.Drawing.Size(48, 13) - Me.lblPreview.TabIndex = 30 - Me.lblPreview.Text = "Preview:" - ' - 'txtScript - ' - Me.txtScript.Location = New System.Drawing.Point(5, 299) - Me.txtScript.Multiline = True - Me.txtScript.Name = "txtScript" - Me.txtScript.ScrollBars = System.Windows.Forms.ScrollBars.Both - Me.txtScript.Size = New System.Drawing.Size(445, 96) - Me.txtScript.TabIndex = 32 - ' - 'ucrInputSaveRFile - ' - Me.ucrInputSaveRFile.AddQuotesIfUnrecognised = True - Me.ucrInputSaveRFile.AutoSize = True - Me.ucrInputSaveRFile.IsMultiline = False - Me.ucrInputSaveRFile.IsReadOnly = False - Me.ucrInputSaveRFile.Location = New System.Drawing.Point(92, 150) - Me.ucrInputSaveRFile.Margin = New System.Windows.Forms.Padding(9) - Me.ucrInputSaveRFile.Name = "ucrInputSaveRFile" - Me.ucrInputSaveRFile.Size = New System.Drawing.Size(145, 21) - Me.ucrInputSaveRFile.TabIndex = 64 - ' - 'ucrChkDisplayGraph - ' - Me.ucrChkDisplayGraph.AutoSize = True - Me.ucrChkDisplayGraph.Checked = False - Me.ucrChkDisplayGraph.Location = New System.Drawing.Point(88, 217) - Me.ucrChkDisplayGraph.Name = "ucrChkDisplayGraph" - Me.ucrChkDisplayGraph.Size = New System.Drawing.Size(113, 23) - Me.ucrChkDisplayGraph.TabIndex = 60 - ' - 'ucrChkSaveDataFrameSingle - ' - Me.ucrChkSaveDataFrameSingle.AutoSize = True - Me.ucrChkSaveDataFrameSingle.Checked = False - Me.ucrChkSaveDataFrameSingle.Location = New System.Drawing.Point(91, 101) - Me.ucrChkSaveDataFrameSingle.Name = "ucrChkSaveDataFrameSingle" - Me.ucrChkSaveDataFrameSingle.Size = New System.Drawing.Size(146, 23) - Me.ucrChkSaveDataFrameSingle.TabIndex = 59 - ' - 'ucrInputSaveDataFrame - ' - Me.ucrInputSaveDataFrame.AddQuotesIfUnrecognised = True - Me.ucrInputSaveDataFrame.AutoSize = True - Me.ucrInputSaveDataFrame.IsMultiline = False - Me.ucrInputSaveDataFrame.IsReadOnly = False - Me.ucrInputSaveDataFrame.Location = New System.Drawing.Point(92, 70) - Me.ucrInputSaveDataFrame.Margin = New System.Windows.Forms.Padding(9) - Me.ucrInputSaveDataFrame.Name = "ucrInputSaveDataFrame" - Me.ucrInputSaveDataFrame.Size = New System.Drawing.Size(145, 21) - Me.ucrInputSaveDataFrame.TabIndex = 57 - ' - 'ucrCboSaveOutputObjectFormat - ' - Me.ucrCboSaveOutputObjectFormat.AddQuotesIfUnrecognised = True - Me.ucrCboSaveOutputObjectFormat.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrCboSaveOutputObjectFormat.GetSetSelectedIndex = -1 - Me.ucrCboSaveOutputObjectFormat.IsReadOnly = False - Me.ucrCboSaveOutputObjectFormat.Location = New System.Drawing.Point(88, 160) - Me.ucrCboSaveOutputObjectFormat.Margin = New System.Windows.Forms.Padding(9) - Me.ucrCboSaveOutputObjectFormat.Name = "ucrCboSaveOutputObjectFormat" - Me.ucrCboSaveOutputObjectFormat.Size = New System.Drawing.Size(141, 21) - Me.ucrCboSaveOutputObjectFormat.TabIndex = 55 - ' - 'ucrCboSaveOutputObjectType - ' - Me.ucrCboSaveOutputObjectType.AddQuotesIfUnrecognised = True - Me.ucrCboSaveOutputObjectType.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrCboSaveOutputObjectType.GetSetSelectedIndex = -1 - Me.ucrCboSaveOutputObjectType.IsReadOnly = False - Me.ucrCboSaveOutputObjectType.Location = New System.Drawing.Point(87, 116) - Me.ucrCboSaveOutputObjectType.Margin = New System.Windows.Forms.Padding(9) - Me.ucrCboSaveOutputObjectType.Name = "ucrCboSaveOutputObjectType" - Me.ucrCboSaveOutputObjectType.Size = New System.Drawing.Size(144, 21) - Me.ucrCboSaveOutputObjectType.TabIndex = 53 - ' - 'ucrSaveObject - ' - Me.ucrSaveObject.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrSaveObject.Location = New System.Drawing.Point(88, 193) - Me.ucrSaveObject.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) - Me.ucrSaveObject.Name = "ucrSaveObject" - Me.ucrSaveObject.Size = New System.Drawing.Size(258, 22) - Me.ucrSaveObject.TabIndex = 35 - ' - 'ucrDataFrameSaveOutputSelect - ' - Me.ucrDataFrameSaveOutputSelect.AutoSize = True - Me.ucrDataFrameSaveOutputSelect.bDropUnusedFilterLevels = False - Me.ucrDataFrameSaveOutputSelect.bUseCurrentFilter = True - Me.ucrDataFrameSaveOutputSelect.Location = New System.Drawing.Point(86, 54) - Me.ucrDataFrameSaveOutputSelect.Margin = New System.Windows.Forms.Padding(0) - Me.ucrDataFrameSaveOutputSelect.Name = "ucrDataFrameSaveOutputSelect" - Me.ucrDataFrameSaveOutputSelect.Size = New System.Drawing.Size(224, 59) - Me.ucrDataFrameSaveOutputSelect.TabIndex = 29 - ' - 'ucrPnlSaveData - ' - Me.ucrPnlSaveData.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrPnlSaveData.Location = New System.Drawing.Point(13, 12) - Me.ucrPnlSaveData.Margin = New System.Windows.Forms.Padding(6) - Me.ucrPnlSaveData.Name = "ucrPnlSaveData" - Me.ucrPnlSaveData.Size = New System.Drawing.Size(402, 36) - Me.ucrPnlSaveData.TabIndex = 47 - ' - 'ucrPnlSaveDataFrame - ' - Me.ucrPnlSaveDataFrame.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrPnlSaveDataFrame.Location = New System.Drawing.Point(5, 48) - Me.ucrPnlSaveDataFrame.Margin = New System.Windows.Forms.Padding(6) - Me.ucrPnlSaveDataFrame.Name = "ucrPnlSaveDataFrame" - Me.ucrPnlSaveDataFrame.Size = New System.Drawing.Size(429, 134) - Me.ucrPnlSaveDataFrame.TabIndex = 65 - ' - 'ucrReceiverGetOutputObject - ' - Me.ucrReceiverGetOutputObject.AutoSize = True - Me.ucrReceiverGetOutputObject.frmParent = Nothing - Me.ucrReceiverGetOutputObject.Location = New System.Drawing.Point(240, 117) - Me.ucrReceiverGetOutputObject.Margin = New System.Windows.Forms.Padding(0) - Me.ucrReceiverGetOutputObject.Name = "ucrReceiverGetOutputObject" - Me.ucrReceiverGetOutputObject.Selector = Nothing - Me.ucrReceiverGetOutputObject.Size = New System.Drawing.Size(138, 20) - Me.ucrReceiverGetOutputObject.strNcFilePath = "" - Me.ucrReceiverGetOutputObject.TabIndex = 27 - Me.ucrReceiverGetOutputObject.ucrSelector = Nothing - ' - 'ucrReceiverGetColumns - ' - Me.ucrReceiverGetColumns.AutoSize = True - Me.ucrReceiverGetColumns.frmParent = Nothing - Me.ucrReceiverGetColumns.Location = New System.Drawing.Point(243, 104) - Me.ucrReceiverGetColumns.Margin = New System.Windows.Forms.Padding(0) - Me.ucrReceiverGetColumns.Name = "ucrReceiverGetColumns" - Me.ucrReceiverGetColumns.Selector = Nothing - Me.ucrReceiverGetColumns.Size = New System.Drawing.Size(137, 105) - Me.ucrReceiverGetColumns.strNcFilePath = "" - Me.ucrReceiverGetColumns.TabIndex = 49 - Me.ucrReceiverGetColumns.ucrSelector = Nothing - ' - 'ucrDataFrameGetDF - ' - Me.ucrDataFrameGetDF.AutoSize = True - Me.ucrDataFrameGetDF.bDropUnusedFilterLevels = False - Me.ucrDataFrameGetDF.bUseCurrentFilter = True - Me.ucrDataFrameGetDF.Location = New System.Drawing.Point(81, 55) - Me.ucrDataFrameGetDF.Margin = New System.Windows.Forms.Padding(0) - Me.ucrDataFrameGetDF.Name = "ucrDataFrameGetDF" - Me.ucrDataFrameGetDF.Size = New System.Drawing.Size(224, 59) - Me.ucrDataFrameGetDF.TabIndex = 31 - ' - 'ucrCboGetOutputObjectType - ' - Me.ucrCboGetOutputObjectType.AddQuotesIfUnrecognised = True - Me.ucrCboGetOutputObjectType.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrCboGetOutputObjectType.GetSetSelectedIndex = -1 - Me.ucrCboGetOutputObjectType.IsReadOnly = False - Me.ucrCboGetOutputObjectType.Location = New System.Drawing.Point(241, 72) - Me.ucrCboGetOutputObjectType.Margin = New System.Windows.Forms.Padding(9) - Me.ucrCboGetOutputObjectType.Name = "ucrCboGetOutputObjectType" - Me.ucrCboGetOutputObjectType.Size = New System.Drawing.Size(137, 21) - Me.ucrCboGetOutputObjectType.TabIndex = 47 - ' - 'ucrPnlGetData - ' - Me.ucrPnlGetData.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrPnlGetData.Location = New System.Drawing.Point(5, 10) - Me.ucrPnlGetData.Margin = New System.Windows.Forms.Padding(6) - Me.ucrPnlGetData.Name = "ucrPnlGetData" - Me.ucrPnlGetData.Size = New System.Drawing.Size(402, 36) - Me.ucrPnlGetData.TabIndex = 42 - ' - 'ucrSelectorGetObject - ' - Me.ucrSelectorGetObject.AutoSize = True - Me.ucrSelectorGetObject.bDropUnusedFilterLevels = False - Me.ucrSelectorGetObject.bShowHiddenColumns = False - Me.ucrSelectorGetObject.bUseCurrentFilter = True - Me.ucrSelectorGetObject.Location = New System.Drawing.Point(9, 52) - Me.ucrSelectorGetObject.Margin = New System.Windows.Forms.Padding(0) - Me.ucrSelectorGetObject.Name = "ucrSelectorGetObject" - Me.ucrSelectorGetObject.Size = New System.Drawing.Size(320, 274) - Me.ucrSelectorGetObject.TabIndex = 34 - ' - 'ucrChkWindow - ' - Me.ucrChkWindow.AutoSize = True - Me.ucrChkWindow.Checked = False - Me.ucrChkWindow.Location = New System.Drawing.Point(233, 94) - Me.ucrChkWindow.Name = "ucrChkWindow" - Me.ucrChkWindow.Size = New System.Drawing.Size(126, 23) - Me.ucrChkWindow.TabIndex = 67 - ' - 'ucrChkInto - ' - Me.ucrChkInto.AutoSize = True - Me.ucrChkInto.Checked = False - Me.ucrChkInto.Location = New System.Drawing.Point(233, 33) - Me.ucrChkInto.Name = "ucrChkInto" - Me.ucrChkInto.Size = New System.Drawing.Size(84, 23) - Me.ucrChkInto.TabIndex = 63 + Me.ucrChkInto.AutoSize = True + Me.ucrChkInto.Checked = False + Me.ucrChkInto.Location = New System.Drawing.Point(233, 33) + Me.ucrChkInto.Name = "ucrChkInto" + Me.ucrChkInto.Size = New System.Drawing.Size(84, 23) + Me.ucrChkInto.TabIndex = 63 ' 'ucrInputSaveData ' @@ -881,6 +779,65 @@ Partial Class dlgScript Me.ucrPnlCommands.Size = New System.Drawing.Size(429, 238) Me.ucrPnlCommands.TabIndex = 47 ' + 'tbPageExamples + ' + Me.tbPageExamples.Controls.Add(Me.cmdHelp) + Me.tbPageExamples.Controls.Add(Me.rdoExampleData) + Me.tbPageExamples.Controls.Add(Me.rdoExampleFunction) + Me.tbPageExamples.Controls.Add(Me.ucrPnlExample) + Me.tbPageExamples.Controls.Add(Me.lstExampleCollection) + Me.tbPageExamples.Controls.Add(Me.Label3) + Me.tbPageExamples.Controls.Add(Me.ucrCboExamplePackages) + Me.tbPageExamples.Location = New System.Drawing.Point(4, 22) + Me.tbPageExamples.Name = "tbPageExamples" + Me.tbPageExamples.Size = New System.Drawing.Size(438, 245) + Me.tbPageExamples.TabIndex = 4 + Me.tbPageExamples.Text = "Library" + Me.tbPageExamples.UseVisualStyleBackColor = True + ' + 'cmdHelp + ' + Me.cmdHelp.Location = New System.Drawing.Point(361, 4) + Me.cmdHelp.Name = "cmdHelp" + Me.cmdHelp.Size = New System.Drawing.Size(75, 23) + Me.cmdHelp.TabIndex = 61 + Me.cmdHelp.Text = "R Help" + Me.cmdHelp.UseVisualStyleBackColor = True + ' + 'rdoExampleData + ' + Me.rdoExampleData.Appearance = System.Windows.Forms.Appearance.Button + Me.rdoExampleData.FlatAppearance.BorderColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoExampleData.FlatAppearance.BorderSize = 2 + Me.rdoExampleData.FlatAppearance.CheckedBackColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoExampleData.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.rdoExampleData.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.rdoExampleData.Location = New System.Drawing.Point(14, 54) + Me.rdoExampleData.Name = "rdoExampleData" + Me.rdoExampleData.Size = New System.Drawing.Size(80, 30) + Me.rdoExampleData.TabIndex = 57 + Me.rdoExampleData.TabStop = True + Me.rdoExampleData.Text = "Data" + Me.rdoExampleData.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + Me.rdoExampleData.UseVisualStyleBackColor = True + ' + 'rdoExampleFunction + ' + Me.rdoExampleFunction.Appearance = System.Windows.Forms.Appearance.Button + Me.rdoExampleFunction.FlatAppearance.BorderColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoExampleFunction.FlatAppearance.BorderSize = 2 + Me.rdoExampleFunction.FlatAppearance.CheckedBackColor = System.Drawing.SystemColors.ActiveCaption + Me.rdoExampleFunction.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.rdoExampleFunction.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.rdoExampleFunction.Location = New System.Drawing.Point(92, 54) + Me.rdoExampleFunction.Name = "rdoExampleFunction" + Me.rdoExampleFunction.Size = New System.Drawing.Size(80, 30) + Me.rdoExampleFunction.TabIndex = 58 + Me.rdoExampleFunction.TabStop = True + Me.rdoExampleFunction.Text = "Function" + Me.rdoExampleFunction.TextAlign = System.Drawing.ContentAlignment.MiddleCenter + Me.rdoExampleFunction.UseVisualStyleBackColor = True + ' 'ucrPnlExample ' Me.ucrPnlExample.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink @@ -890,6 +847,42 @@ Partial Class dlgScript Me.ucrPnlExample.Size = New System.Drawing.Size(402, 34) Me.ucrPnlExample.TabIndex = 56 ' + 'lstExampleCollection + ' + Me.lstExampleCollection.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.clmDatasets, Me.clmDesc}) + Me.lstExampleCollection.FullRowSelect = True + Me.lstExampleCollection.HideSelection = False + Me.lstExampleCollection.Location = New System.Drawing.Point(3, 93) + Me.lstExampleCollection.MultiSelect = False + Me.lstExampleCollection.Name = "lstExampleCollection" + Me.lstExampleCollection.ShowGroups = False + Me.lstExampleCollection.ShowItemToolTips = True + Me.lstExampleCollection.Size = New System.Drawing.Size(415, 146) + Me.lstExampleCollection.Sorting = System.Windows.Forms.SortOrder.Ascending + Me.lstExampleCollection.TabIndex = 53 + Me.lstExampleCollection.UseCompatibleStateImageBehavior = False + Me.lstExampleCollection.View = System.Windows.Forms.View.Details + ' + 'clmDatasets + ' + Me.clmDatasets.Text = "Data" + Me.clmDatasets.Width = 142 + ' + 'clmDesc + ' + Me.clmDesc.Text = "Description" + Me.clmDesc.Width = 266 + ' + 'Label3 + ' + Me.Label3.AutoSize = True + Me.Label3.Location = New System.Drawing.Point(13, 5) + Me.Label3.Margin = New System.Windows.Forms.Padding(2, 0, 2, 0) + Me.Label3.Name = "Label3" + Me.Label3.Size = New System.Drawing.Size(50, 13) + Me.Label3.TabIndex = 52 + Me.Label3.Text = "Package" + ' 'ucrCboExamplePackages ' Me.ucrCboExamplePackages.AddQuotesIfUnrecognised = True @@ -902,6 +895,25 @@ Partial Class dlgScript Me.ucrCboExamplePackages.Size = New System.Drawing.Size(137, 21) Me.ucrCboExamplePackages.TabIndex = 51 ' + 'lblPreview + ' + Me.lblPreview.AutoSize = True + Me.lblPreview.ImeMode = System.Windows.Forms.ImeMode.NoControl + Me.lblPreview.Location = New System.Drawing.Point(9, 281) + Me.lblPreview.Name = "lblPreview" + Me.lblPreview.Size = New System.Drawing.Size(48, 13) + Me.lblPreview.TabIndex = 30 + Me.lblPreview.Text = "Preview:" + ' + 'txtScript + ' + Me.txtScript.Location = New System.Drawing.Point(5, 299) + Me.txtScript.Multiline = True + Me.txtScript.Name = "txtScript" + Me.txtScript.ScrollBars = System.Windows.Forms.ScrollBars.Both + Me.txtScript.Size = New System.Drawing.Size(445, 96) + Me.txtScript.TabIndex = 32 + ' 'ucrBase ' Me.ucrBase.AutoSize = True @@ -912,6 +924,69 @@ Partial Class dlgScript Me.ucrBase.Size = New System.Drawing.Size(408, 52) Me.ucrBase.TabIndex = 16 ' + 'rdoVariable + ' + Me.rdoVariable.AutoSize = True + Me.rdoVariable.Location = New System.Drawing.Point(49, 54) + Me.rdoVariable.Margin = New System.Windows.Forms.Padding(2) + Me.rdoVariable.Name = "rdoVariable" + Me.rdoVariable.Size = New System.Drawing.Size(92, 17) + Me.rdoVariable.TabIndex = 66 + Me.rdoVariable.TabStop = True + Me.rdoVariable.Text = "From Variable:" + Me.rdoVariable.UseVisualStyleBackColor = True + ' + 'ucrInputSaveColumn + ' + Me.ucrInputSaveColumn.AddQuotesIfUnrecognised = True + Me.ucrInputSaveColumn.AutoSize = True + Me.ucrInputSaveColumn.IsMultiline = False + Me.ucrInputSaveColumn.IsReadOnly = False + Me.ucrInputSaveColumn.Location = New System.Drawing.Point(207, 57) + Me.ucrInputSaveColumn.Margin = New System.Windows.Forms.Padding(9) + Me.ucrInputSaveColumn.Name = "ucrInputSaveColumn" + Me.ucrInputSaveColumn.Size = New System.Drawing.Size(105, 21) + Me.ucrInputSaveColumn.TabIndex = 67 + ' + 'ucrInputDataframeColumn + ' + Me.ucrInputDataframeColumn.AddQuotesIfUnrecognised = True + Me.ucrInputDataframeColumn.AutoSize = True + Me.ucrInputDataframeColumn.IsMultiline = False + Me.ucrInputDataframeColumn.IsReadOnly = False + Me.ucrInputDataframeColumn.Location = New System.Drawing.Point(206, 83) + Me.ucrInputDataframeColumn.Margin = New System.Windows.Forms.Padding(9) + Me.ucrInputDataframeColumn.Name = "ucrInputDataframeColumn" + Me.ucrInputDataframeColumn.Size = New System.Drawing.Size(106, 21) + Me.ucrInputDataframeColumn.TabIndex = 68 + ' + 'lblSaveColumn + ' + Me.lblSaveColumn.AutoSize = True + Me.lblSaveColumn.Location = New System.Drawing.Point(139, 57) + Me.lblSaveColumn.Name = "lblSaveColumn" + Me.lblSaveColumn.Size = New System.Drawing.Size(49, 13) + Me.lblSaveColumn.TabIndex = 69 + Me.lblSaveColumn.Text = "Name(s):" + ' + 'lblSaveDataFrame + ' + Me.lblSaveDataFrame.AutoSize = True + Me.lblSaveDataFrame.Location = New System.Drawing.Point(139, 83) + Me.lblSaveDataFrame.Name = "lblSaveDataFrame" + Me.lblSaveDataFrame.Size = New System.Drawing.Size(65, 13) + Me.lblSaveDataFrame.TabIndex = 70 + Me.lblSaveDataFrame.Text = "Data Frame:" + ' + 'lblSaveText + ' + Me.lblSaveText.AutoSize = True + Me.lblSaveText.Location = New System.Drawing.Point(317, 61) + Me.lblSaveText.Name = "lblSaveText" + Me.lblSaveText.Size = New System.Drawing.Size(116, 13) + Me.lblSaveText.TabIndex = 71 + Me.lblSaveText.Text = "(separated by commas)" + ' 'dlgScript ' Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) @@ -1009,4 +1084,10 @@ Partial Class dlgScript Friend WithEvents rdoFromRFile As RadioButton Friend WithEvents rdoDataFrame As RadioButton Friend WithEvents ucrPnlSaveDataFrame As UcrPanel + Friend WithEvents lblSaveText As Label + Friend WithEvents lblSaveDataFrame As Label + Friend WithEvents lblSaveColumn As Label + Friend WithEvents ucrInputDataframeColumn As ucrInputTextBox + Friend WithEvents ucrInputSaveColumn As ucrInputTextBox + Friend WithEvents rdoVariable As RadioButton End Class diff --git a/instat/dlgScript.vb b/instat/dlgScript.vb index 56b6fca3e7..39835aaab7 100644 --- a/instat/dlgScript.vb +++ b/instat/dlgScript.vb @@ -78,6 +78,7 @@ Public Class dlgScript ucrPnlSaveDataFrame.AddRadioButton(rdoDataFrame) ucrPnlSaveDataFrame.AddRadioButton(rdoFromRFile) + ucrPnlSaveDataFrame.AddRadioButton(rdoVariable) ucrChkSaveDataFrameSingle.SetText("Single") @@ -777,6 +778,11 @@ Public Class dlgScript Private Sub HideShowSaveDataFrameControls() ucrInputSaveRFile.SetVisible(False) ucrInputSaveDataFrame.SetVisible(False) + ucrInputSaveColumn.SetVisible(False) + ucrInputDataframeColumn.SetVisible(False) + lblSaveColumn.Visible = False + lblSaveDataFrame.Visible = False + lblSaveText.Visible = False ucrChkSaveDataFrameSingle.SetVisible(False) If rdoDataFrame.Checked Then ucrInputSaveDataFrame.SetVisible(True) @@ -786,7 +792,52 @@ Public Class dlgScript ElseIf rdoFromRFile.Checked Then ucrInputSaveRFile.SetVisible(True) ucrInputSaveRFile.OnControlValueChanged() + ElseIf rdoVariable.Checked Then + ucrInputSaveColumn.SetVisible(True) + ucrInputDataframeColumn.SetVisible(True) + lblSaveText.Visible = True + lblSaveColumn.Visible = True + lblSaveDataFrame.Visible = True + ucrChkSaveDataFrameSingle.SetVisible(True) + ucrInputSaveDataFrame.OnControlValueChanged() End If End Sub + Private Sub ucrInputDataframeColumn_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrInputDataframeColumn.ControlContentsChanged, ucrInputSaveColumn.ControlContentsChanged, + ucrChkSaveDataFrameSingle.ControlContentsChanged + Dim strScript As String = "" + + If rdoVariable.Checked Then + If Not ucrInputDataframeColumn.IsEmpty() AndAlso Not ucrInputSaveColumn.IsEmpty Then + Dim clsDataFrameFunction As New RFunction + Dim clsImportRFunction As New RFunction + Dim strColumneName As String = ucrInputSaveColumn.GetText() + Dim strDataFrameName As String = ucrInputDataframeColumn.GetText() + + clsImportRFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$import_data") + clsDataFrameFunction.SetRCommand("data.frame") + + Dim strAssignedScript As String = "" + clsDataFrameFunction.AddParameter("dataframe", ucrInputSaveColumn.GetText(), bIncludeArgumentName:=False) + clsDataFrameFunction.SetAssignTo(ucrInputDataframeColumn.GetText) + clsDataFrameFunction.ToScript(strScript:=strAssignedScript) + + If ucrChkSaveDataFrameSingle.Checked Then + ' If it's a single data frame then wrap it into a list + Dim clsDataListRFunction As New RFunction + clsDataListRFunction.SetRCommand("list") + clsDataListRFunction.AddParameter(strParameterName:=strDataFrameName, strParameterValue:=strDataFrameName) + clsImportRFunction.AddParameter(strParameterName:="data_tables", clsRFunctionParameter:=clsDataListRFunction) + Else + ' If it's already a list of data frames, then add the name directly + clsImportRFunction.AddParameter(strParameterName:="data_tables", strParameterValue:=strDataFrameName) + End If + + strScript = "# Save variables " & """" & strColumneName & """" & "into data frame " & """" & strDataFrameName & """" & Environment.NewLine & strAssignedScript & clsImportRFunction.ToScript() + + End If + End If + PreviewScript(strScript) + End Sub + End Class \ No newline at end of file From 821c32a8fd8f57760247039ffe60b86dc9aa8ae3 Mon Sep 17 00:00:00 2001 From: lilyclements Date: Fri, 17 Jan 2025 17:53:07 +0000 Subject: [PATCH 17/35] improving efficiency in crop_definitions R code --- .../static/InstatObject/R/instat_object_R6.R | 287 +++++++++++------- 1 file changed, 170 insertions(+), 117 deletions(-) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index 5f7a6c88e4..42bb315d2e 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -2215,11 +2215,8 @@ DataBook$set("public","get_variable_sets", function(data_name, set_names, force_ } ) -DataBook$set("public", "crops_definitions", function(data_name, year, station, rain, day, rain_totals, plant_days, plant_lengths, start_check = TRUE, season_data_name, start_day, end_day, definition_props = TRUE, print_table = TRUE) { - plant_day_name <- "plant_day" - plant_length_name <- "plant_length" - rain_total_name <- "rain_total" - +DataBook$set("public", "crops_definitions", function(data_name, year, station, rain, day, rain_totals, plant_days, plant_lengths, start_check = TRUE, season_data_name, start_day, end_day, return_crops_table = TRUE, definition_props = TRUE, print_table = TRUE){ + # Run checks is_station <- !missing(station) if(missing(year)) stop("Year column must be specified.") @@ -2233,6 +2230,11 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r year_col <- self$get_columns_from_data(data_name, year) unique_year <- na.omit(unique(year_col)) + # Set names + plant_day_name <- "plant_day" + plant_length_name <- "plant_length" + rain_total_name <- "rain_total" + expand_list <- list(rain_totals, plant_lengths, plant_days, unique_year) names_list <- c(rain_total_name, plant_length_name, plant_day_name, year) @@ -2253,8 +2255,7 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r vars <- c(season_by, start_day, end_day) season_data <- season_data %>% dplyr::select(!!! rlang::syms(vars)) df <- dplyr::left_join(df, season_data, by = join_by) - } - else { + } else { col_names <- c(by, start_day, end_day) season_data <- daily_data %>% dplyr::select(!!! rlang::syms(col_names)) %>% @@ -2264,133 +2265,185 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r df <- dplyr::left_join(df, season_data, by = by) } - # Plant day condition - if(start_check %in% c("yes", "both")) { - df$plant_day_cond <- (df[[start_day]] <= df[[plant_day_name]]) - } - - # Plant length condition - df$length_cond <- (df[[plant_day_name]] + df[[plant_length_name]] <= df[[end_day]]) + ## Onto the calculation + proportion_df <- NULL + crops_def_table <- NULL + i <- 1 - # Rain total condition - # Create a column for the rain total actuals initialised with NA - df[["rain_total_actual"]] <- NA + calculate_rain_condition <- function(data){ + data <- data %>% + dplyr::select(-rain_total_name) %>% + unique() - # Vectorise the conditions for each - for (i in 1:nrow(df)) { - # Create a condition to filter the daily data based on the year, day, and plant day/length - ind <- daily_data[[year]] == df[[year]][i] & - daily_data[[day]] >= df[[plant_day_name]][i] & - daily_data[[day]] < (df[[plant_day_name]][i] + df[[plant_length_name]][i]) + for (i in 1:nrow(data)) { + # Create a condition to filter the daily data based on the year, day, and plant day/length + ind <- daily_data[[year]] == data[[year]][i] & + daily_data[[day]] >= data[[plant_day_name]][i] & + daily_data[[day]] < (data[[plant_day_name]][i] + data[[plant_length_name]][i]) - if (is_station) { - ind <- ind & (daily_data[[station]] == df[[station]][i]) - } + if (is_station) { + ind <- ind & (daily_data[[station]] == data[[station]][i]) + } - # Filter the daily data based on the condition - rain_values <- daily_data[[rain]][ind] + # Filter the daily data based on the condition + rain_values <- daily_data[[rain]][ind] - # Calculate the sum of rain values and check conditions - sum_rain <- sum(rain_values, na.rm = TRUE) + # Calculate the sum of rain values and check conditions + sum_rain <- sum(rain_values, na.rm = TRUE) - if (length(rain_values) + 1 < df[[plant_length_name]][i] || (anyNA(rain_values) && sum_rain < df[[rain_total_name]][i])) { - sum_rain <- NA - } + if (anyNA(rain_values)){ #&& sum_rain < data[[rain_total_name]][i]){ + sum_rain <- -1 * sum_rain # as a way to tag the sum_rain value for later, we set as -ve value. + } + + if (length(rain_values) + 1 < data[[plant_length_name]][i]) { + sum_rain <- NA + } - # Assign the calculated sum to the respective row in the result dataframe - df[["rain_total_actual"]][i] <- sum_rain - } - df$rain_cond <- df[[rain_total_name]] <= df[["rain_total_actual"]] + # Assign the calculated sum to the respective row in the result dataframe + data[["rain_total_actual"]][i] <- sum_rain + } + return(data) +} - # All three conditions met - if (start_check == "yes"){ - df$overall_cond <- df$plant_day_cond & df$length_cond & df$rain_cond - } else if (start_check == "no"){ - df$overall_cond <- TRUE & df$length_cond & df$rain_cond - } else { - df$overall_cond_with_start <- df$plant_day_cond & df$length_cond & df$rain_cond - df$overall_cond_no_start <- TRUE & df$length_cond & df$rain_cond + # run by plant day and plant_length + for (day_i in plant_days){ + for (length_i in plant_lengths){ + + # for each plant length and plant day combination, calculate the total rainfall in that period. + filtered_data_1 <- df %>% filter(plant_day == day_i) %>% filter(plant_length == length_i) + + # Now run to get the rain conditions + filtered_data_1 <- calculate_rain_condition(data = filtered_data_1) + + # so: filtered_data_1 contains the total rainfall that occurred in that period for all the plant_day and plant_length combinations + # we now split by our different rain_total_actual conditions. + # we do this here to avoid calculating it multiple times. + for (rain_i in rain_totals){ + filtered_data <- filtered_data_1 %>% dplyr::mutate(rain_total = rain_i) %>% + dplyr::select(c(rain_total_name, plant_length_name, plant_day_name, everything())) + + # take the rows < 0 and run a check. We want to check + # if (anyNA(rain_values) && sum_rain < data[[rain_total_name]][i]) { sum_rain <- NA + # we do this here because we want to avoid running rain_total in calculate_rain_condition for efficiency purposes. + filtered_data <- filtered_data %>% + dplyr::mutate(rain_total_actual = ifelse(rain_total_actual < 0, ifelse(-1*rain_total_actual < rain_total, NA, -1*rain_total_actual), rain_total_actual)) + + if (!missing(station)){ + filtered_data <- filtered_data %>% + dplyr::group_by(station, year) + } else { + filtered_data <- filtered_data %>% + dplyr::group_by(year) + } + + filtered_data <- filtered_data %>% + # first add a column (T/F) that states that it is in the rainfall period or not. + dplyr::mutate(plant_day_cond = start_rain <= plant_day, + length_cond = plant_day + plant_length <= end_rains, + rain_cond = rain_i <= rain_total_actual) %>% + dplyr::ungroup() + + if (start_check == "both"){ + + filtered_data <- filtered_data %>% + dplyr::mutate( + overall_cond_with_start = plant_day_cond & length_cond & rain_cond, + overall_cond_no_start = length_cond & rain_cond) + proportion_data <- filtered_data %>% + dplyr::summarise(prop_success_with_start = sum(overall_cond_with_start, na.rm = TRUE)/length(na.omit(overall_cond_with_start)), + prop_success_no_start = sum(overall_cond_no_start, na.rm = TRUE)/length(na.omit(overall_cond_no_start))) + } else { + filtered_data <- filtered_data %>% + dplyr::mutate( + overall_cond = case_when( + start_check == "yes" ~ plant_day_cond & length_cond & rain_cond, + start_check == "no" ~ TRUE & length_cond & rain_cond) + ) + + proportion_data <- filtered_data %>% + dplyr::summarise(prop_success = sum(overall_cond, na.rm = TRUE)/length(na.omit(overall_cond))) + } + + if (return_crops_table){ + crops_def_table[[i]] <- filtered_data %>% dplyr::mutate(rain_total = rain_i, + plant_length = length_i, + plant_day = day_i) + } + if (definition_props){ + proportion_df[[i]] <- proportion_data %>% dplyr::mutate(rain_total = rain_i, + plant_length = length_i, + plant_day = day_i) + } + i <- i + 1 + } + } } - crops_name <- "crop_def" - crops_name <- next_default_item(prefix = crops_name, existing_names = self$get_data_names(), include_index = FALSE) - data_tables <- list(df) - names(data_tables) <- crops_name - self$import_data(data_tables = data_tables) - - if(season_data_name != data_name) { - crops_by <- season_by - names(crops_by) <- by - self$add_link(crops_name, season_data_name, crops_by, keyed_link_label) - } - - if(definition_props) { - calc_from <- list() - if(!missing(station)) calc_from[[length(calc_from) + 1]] <- station - calc_from[[length(calc_from) + 1]] <- plant_day_name - calc_from[[length(calc_from) + 1]] <- plant_length_name - calc_from[[length(calc_from) + 1]] <- rain_total_name - names(calc_from) <- rep(crops_name, length(calc_from)) - grouping <- instat_calculation$new(type = "by", calculated_from = calc_from) + if (return_crops_table){ + # here we get crop_def and import it as a new DF + crops_def_table <- dplyr::bind_rows(crops_def_table) + crops_name <- "crop_def" + crops_name <- next_default_item(prefix = crops_name, existing_names = self$get_data_names(), include_index = FALSE) + data_tables <- list(crops_def_table) + names(data_tables) <- crops_name + if(season_data_name != data_name) { + crops_by <- season_by + names(crops_by) <- by + self$add_link(crops_name, season_data_name, crops_by, keyed_link_label) + } + self$import_data(data_tables = data_tables) + } + if (definition_props){ + prop_data_frame <- dplyr::bind_rows(proportion_df) %>% + dplyr::select(c(rain_total_name, plant_length_name, plant_day_name, everything())) + + prop_name <- "crop_prop" + prop_name <- next_default_item(prefix = prop_name, existing_names = self$get_data_names(), include_index = FALSE) + data_tables <- list(prop_data_frame) + names(data_tables) <- prop_name + self$import_data(data_tables = data_tables) - if (start_check %in% c("yes", "no")){ - prop_calc_from <- list("overall_cond") - names(prop_calc_from) <- crops_name - propor_table <- instat_calculation$new(function_exp="sum(overall_cond, na.rm = TRUE)/length(na.omit(overall_cond))", - save = 2, calculated_from = prop_calc_from, - manipulations = list(grouping), - type="summary", result_name = "prop_success", result_data_frame = "crop_prop") - prop_data_frame <- self$run_instat_calculation(propor_table, display = TRUE) - if(print_table) { + if(print_table) { + if (start_check %in% c("yes", "no")){ prop_data_frame$prop_success <- round(prop_data_frame$prop_success, 2) - prop_table_unstacked <- reshape2::dcast(formula = as.formula(paste(if(!missing(station)) paste(station, "+"), plant_length_name, "+", rain_total_name, "~", plant_day_name)), data = prop_data_frame, value.var = "prop_success") - if(!missing(station)) f <- interaction(prop_table_unstacked[[station]], prop_table_unstacked[[plant_length_name]], lex.order = TRUE) - else f <- prop_table_unstacked[[plant_length_name]] - prop_table_split <- split(prop_table_unstacked, f) - return(prop_table_split) - } - } else { - prop_calc_from_with_start <- list("overall_cond_with_start") - names(prop_calc_from_with_start) <- crops_name - propor_table_with_start <- instat_calculation$new(function_exp="sum(overall_cond_with_start, na.rm = TRUE)/length(na.omit(overall_cond_with_start))", - save = 2, calculated_from = prop_calc_from_with_start, - manipulations = list(grouping), - type="summary", result_name = "prop_success", result_data_frame = "crop_prop_with_start") - prop_data_frame_with_start <- self$run_instat_calculation(propor_table_with_start, display = TRUE) - - prop_calc_from_no_start <- list("overall_cond_no_start") - names(prop_calc_from_no_start) <- crops_name - propor_table_no_start <- instat_calculation$new(function_exp="sum(overall_cond_no_start, na.rm = TRUE)/length(na.omit(overall_cond_no_start))", - save = 2, calculated_from = prop_calc_from_no_start, - manipulations = list(grouping), - type="summary", result_name = "prop_success", result_data_frame = "crop_prop_no_start") - prop_data_frame_no_start <- self$run_instat_calculation(propor_table_no_start, display = TRUE) - - if(print_table) { - prop_data_frame_with_start$prop_success <- round(prop_data_frame_with_start$prop_success, 2) - prop_table_unstacked_with_start <- reshape2::dcast(formula = as.formula(paste(if(!missing(station)) paste(station, "+"), plant_length_name, "+", rain_total_name, "~", plant_day_name)), data = prop_data_frame_with_start, value.var = "prop_success") - if(!missing(station)) f <- interaction(prop_table_unstacked_with_start[[station]], prop_table_unstacked_with_start[[plant_length_name]], lex.order = TRUE) - else f <- prop_table_unstacked_with_start[[plant_length_name]] - prop_table_split_with_start <- split(prop_table_unstacked_with_start, f) + prop_table_unstacked <- reshape2::dcast(formula = as.formula(paste(if(!missing(station)) paste(station, "+"), plant_length_name, "+", rain_total_name, "~", plant_day_name)), data = prop_data_frame, value.var = "prop_success") + if(!missing(station)) f <- interaction(prop_table_unstacked[[station]], prop_table_unstacked[[plant_length_name]], lex.order = TRUE) + else f <- prop_table_unstacked[[plant_length_name]] + prop_table_split <- split(prop_table_unstacked, f) + return(prop_table_split) + } else { + prop_data_frame_with_start <- prop_data_frame %>% + dplyr::select(-c("prop_success_no_start")) %>% + tidyr::pivot_wider(id_cols = c(station, plant_length_name, rain_total_name), names_from = plant_day_name, values_from = prop_success_with_start) + if(!missing(station)) f <- interaction(prop_data_frame_with_start[[station]], prop_data_frame_with_start[[plant_length_name]], lex.order = TRUE) + else f <- prop_data_frame_with_start[[plant_length_name]] + prop_table_split_with_start <- split(prop_data_frame_with_start, f) - prop_data_frame_no_start$prop_success <- round(prop_data_frame_no_start$prop_success, 2) - prop_table_unstacked_no_start <- reshape2::dcast(formula = as.formula(paste(if(!missing(station)) paste(station, "+"), plant_length_name, "+", rain_total_name, "~", plant_day_name)), data = prop_data_frame_no_start, value.var = "prop_success") - if(!missing(station)) f <- interaction(prop_table_unstacked_no_start[[station]], prop_table_unstacked_no_start[[plant_length_name]], lex.order = TRUE) - else f <- prop_table_unstacked_no_start[[plant_length_name]] - prop_table_split_no_start <- split(prop_table_unstacked_no_start, f) + prop_data_frame_no_start <- prop_data_frame %>% + dplyr::select(-c("prop_success_with_start")) %>% + tidyr::pivot_wider(id_cols = c(station, plant_length_name, rain_total_name), names_from = plant_day_name, values_from = prop_success_no_start) + if(!missing(station)) f <- interaction(prop_data_frame_no_start[[station]], prop_data_frame_no_start[[plant_length_name]], lex.order = TRUE) + else f <- prop_data_frame_no_start[[plant_length_name]] + prop_table_split_with_start <- split(prop_data_frame_no_start, f) - # Create an empty list to store the merged data - merged_list <- list() - - # Vectorize the addition of source indicators and merging of data frames - prop_table_split_with_start <- lapply(prop_table_split_with_start, function(df) { - df$source <- 'with start' - return(df) - }) + # Create an empty list to store the merged data + #merged_list <- list() + # + # Vectorize the addition of source indicators and merging of data frames + # prop_table_split_with_start <- lapply(prop_table_split_with_start, function(df) { + # df$source <- 'with start' + # return(df) + # }) } } } -}) + + if (return_crops_table & definition_props){ + # Add Link + data_book$add_link(from_data_frame = crops_name, to_data_frame = prop_name, link_pairs=c(rain_total = rain_total_name, plant_length = plant_length_name, plant_day = plant_day_name), type="keyed_link") + } +} +) #' Converting grid (wide) format daily climatic data into tidy (long format) data #' @param x Input data frame From dedc57239a6447527071a39179b75c676e20d243 Mon Sep 17 00:00:00 2001 From: lilyclements Date: Fri, 17 Jan 2025 18:32:08 +0000 Subject: [PATCH 18/35] fix in print return table --- .../static/InstatObject/R/instat_object_R6.R | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index 42bb315d2e..53fe3b1ce7 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -2402,6 +2402,9 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r data_tables <- list(prop_data_frame) names(data_tables) <- prop_name self$import_data(data_tables = data_tables) + + # Add Link + if (return_crops_table) data_book$add_link(from_data_frame = crops_name, to_data_frame = prop_name, link_pairs=c(rain_total = rain_total_name, plant_length = plant_length_name, plant_day = plant_day_name), type="keyed_link") if(print_table) { if (start_check %in% c("yes", "no")){ @@ -2410,38 +2413,30 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r if(!missing(station)) f <- interaction(prop_table_unstacked[[station]], prop_table_unstacked[[plant_length_name]], lex.order = TRUE) else f <- prop_table_unstacked[[plant_length_name]] prop_table_split <- split(prop_table_unstacked, f) - return(prop_table_split) + print(prop_table_split) } else { - prop_data_frame_with_start <- prop_data_frame %>% - dplyr::select(-c("prop_success_no_start")) %>% - tidyr::pivot_wider(id_cols = c(station, plant_length_name, rain_total_name), names_from = plant_day_name, values_from = prop_success_with_start) + prop_data_frame_with_start <- prop_data_frame %>% + dplyr::select(-c("prop_success_no_start")) + prop_data_frame_with_start <- reshape2::dcast(formula = as.formula(paste(if(!missing(station)) paste(station, "+"), plant_length_name, "+", rain_total_name, "~", plant_day_name)), data = prop_data_frame_with_start, value.var = "prop_success_with_start") if(!missing(station)) f <- interaction(prop_data_frame_with_start[[station]], prop_data_frame_with_start[[plant_length_name]], lex.order = TRUE) else f <- prop_data_frame_with_start[[plant_length_name]] prop_table_split_with_start <- split(prop_data_frame_with_start, f) prop_data_frame_no_start <- prop_data_frame %>% - dplyr::select(-c("prop_success_with_start")) %>% - tidyr::pivot_wider(id_cols = c(station, plant_length_name, rain_total_name), names_from = plant_day_name, values_from = prop_success_no_start) + dplyr::select(-c("prop_success_with_start")) + prop_data_frame_no_start <- reshape2::dcast(formula = as.formula(paste(if(!missing(station)) paste(station, "+"), plant_length_name, "+", rain_total_name, "~", plant_day_name)), data = prop_data_frame_no_start, value.var = "prop_success_no_start") if(!missing(station)) f <- interaction(prop_data_frame_no_start[[station]], prop_data_frame_no_start[[plant_length_name]], lex.order = TRUE) else f <- prop_data_frame_no_start[[plant_length_name]] - prop_table_split_with_start <- split(prop_data_frame_no_start, f) + prop_table_split_no_start <- split(prop_data_frame_no_start, f) # Create an empty list to store the merged data - #merged_list <- list() - # - # Vectorize the addition of source indicators and merging of data frames - # prop_table_split_with_start <- lapply(prop_table_split_with_start, function(df) { - # df$source <- 'with start' - # return(df) - # }) + print("Proportion with start check") + print(prop_table_split_with_start) + print("Proportion without start check") + print(prop_table_split_no_start) } } } - - if (return_crops_table & definition_props){ - # Add Link - data_book$add_link(from_data_frame = crops_name, to_data_frame = prop_name, link_pairs=c(rain_total = rain_total_name, plant_length = plant_length_name, plant_day = plant_day_name), type="keyed_link") - } } ) From 2ac1d11363747581146f0621d8f77c1605741921 Mon Sep 17 00:00:00 2001 From: Derrick Agorhom <76208189+derekagorhom@users.noreply.github.com> Date: Mon, 20 Jan 2025 09:32:32 +0100 Subject: [PATCH 19/35] Cosmetic and Code Changes --- instat/dlgScript.Designer.vb | 192 +++++++++++++++++------------------ instat/dlgScript.vb | 2 +- 2 files changed, 97 insertions(+), 97 deletions(-) diff --git a/instat/dlgScript.Designer.vb b/instat/dlgScript.Designer.vb index 2e1e365de5..9e5408b456 100644 --- a/instat/dlgScript.Designer.vb +++ b/instat/dlgScript.Designer.vb @@ -24,8 +24,14 @@ Partial Class dlgScript Private Sub InitializeComponent() Me.tbFeatures = New System.Windows.Forms.TabControl() Me.tbPageSaveData = New System.Windows.Forms.TabPage() - Me.ucrInputSaveRFile = New instat.ucrInputTextBox() Me.rdoFromRFile = New System.Windows.Forms.RadioButton() + Me.ucrInputSaveRFile = New instat.ucrInputTextBox() + Me.lblSaveText = New System.Windows.Forms.Label() + Me.lblSaveDataFrame = New System.Windows.Forms.Label() + Me.lblSaveColumn = New System.Windows.Forms.Label() + Me.ucrInputDataframeColumn = New instat.ucrInputTextBox() + Me.ucrInputSaveColumn = New instat.ucrInputTextBox() + Me.rdoVariable = New System.Windows.Forms.RadioButton() Me.rdoDataFrame = New System.Windows.Forms.RadioButton() Me.ucrChkDisplayGraph = New instat.ucrCheck() Me.ucrChkSaveDataFrameSingle = New instat.ucrCheck() @@ -89,12 +95,6 @@ Partial Class dlgScript Me.lblPreview = New System.Windows.Forms.Label() Me.txtScript = New System.Windows.Forms.TextBox() Me.ucrBase = New instat.ucrButtons() - Me.rdoVariable = New System.Windows.Forms.RadioButton() - Me.ucrInputSaveColumn = New instat.ucrInputTextBox() - Me.ucrInputDataframeColumn = New instat.ucrInputTextBox() - Me.lblSaveColumn = New System.Windows.Forms.Label() - Me.lblSaveDataFrame = New System.Windows.Forms.Label() - Me.lblSaveText = New System.Windows.Forms.Label() Me.tbFeatures.SuspendLayout() Me.tbPageSaveData.SuspendLayout() Me.tbPageGetData.SuspendLayout() @@ -111,19 +111,19 @@ Partial Class dlgScript Me.tbFeatures.Location = New System.Drawing.Point(8, 7) Me.tbFeatures.Name = "tbFeatures" Me.tbFeatures.SelectedIndex = 0 - Me.tbFeatures.Size = New System.Drawing.Size(446, 271) + Me.tbFeatures.Size = New System.Drawing.Size(446, 304) Me.tbFeatures.TabIndex = 31 ' 'tbPageSaveData ' + Me.tbPageSaveData.Controls.Add(Me.rdoFromRFile) + Me.tbPageSaveData.Controls.Add(Me.ucrInputSaveRFile) Me.tbPageSaveData.Controls.Add(Me.lblSaveText) Me.tbPageSaveData.Controls.Add(Me.lblSaveDataFrame) Me.tbPageSaveData.Controls.Add(Me.lblSaveColumn) Me.tbPageSaveData.Controls.Add(Me.ucrInputDataframeColumn) Me.tbPageSaveData.Controls.Add(Me.ucrInputSaveColumn) Me.tbPageSaveData.Controls.Add(Me.rdoVariable) - Me.tbPageSaveData.Controls.Add(Me.ucrInputSaveRFile) - Me.tbPageSaveData.Controls.Add(Me.rdoFromRFile) Me.tbPageSaveData.Controls.Add(Me.rdoDataFrame) Me.tbPageSaveData.Controls.Add(Me.ucrChkDisplayGraph) Me.tbPageSaveData.Controls.Add(Me.ucrChkSaveDataFrameSingle) @@ -141,39 +141,102 @@ Partial Class dlgScript Me.tbPageSaveData.Controls.Add(Me.ucrPnlSaveDataFrame) Me.tbPageSaveData.Location = New System.Drawing.Point(4, 22) Me.tbPageSaveData.Name = "tbPageSaveData" - Me.tbPageSaveData.Size = New System.Drawing.Size(438, 245) + Me.tbPageSaveData.Size = New System.Drawing.Size(438, 278) Me.tbPageSaveData.TabIndex = 2 Me.tbPageSaveData.Text = "Save Data" Me.tbPageSaveData.UseVisualStyleBackColor = True ' + 'rdoFromRFile + ' + Me.rdoFromRFile.AutoSize = True + Me.rdoFromRFile.Location = New System.Drawing.Point(49, 202) + Me.rdoFromRFile.Margin = New System.Windows.Forms.Padding(2) + Me.rdoFromRFile.Name = "rdoFromRFile" + Me.rdoFromRFile.Size = New System.Drawing.Size(81, 17) + Me.rdoFromRFile.TabIndex = 63 + Me.rdoFromRFile.TabStop = True + Me.rdoFromRFile.Text = "From R File:" + Me.rdoFromRFile.UseVisualStyleBackColor = True + ' 'ucrInputSaveRFile ' Me.ucrInputSaveRFile.AddQuotesIfUnrecognised = True Me.ucrInputSaveRFile.AutoSize = True Me.ucrInputSaveRFile.IsMultiline = False Me.ucrInputSaveRFile.IsReadOnly = False - Me.ucrInputSaveRFile.Location = New System.Drawing.Point(247, 137) + Me.ucrInputSaveRFile.Location = New System.Drawing.Point(67, 228) Me.ucrInputSaveRFile.Margin = New System.Windows.Forms.Padding(9) Me.ucrInputSaveRFile.Name = "ucrInputSaveRFile" Me.ucrInputSaveRFile.Size = New System.Drawing.Size(145, 21) Me.ucrInputSaveRFile.TabIndex = 64 ' - 'rdoFromRFile + 'lblSaveText ' - Me.rdoFromRFile.AutoSize = True - Me.rdoFromRFile.Location = New System.Drawing.Point(238, 114) - Me.rdoFromRFile.Margin = New System.Windows.Forms.Padding(2) - Me.rdoFromRFile.Name = "rdoFromRFile" - Me.rdoFromRFile.Size = New System.Drawing.Size(81, 17) - Me.rdoFromRFile.TabIndex = 63 - Me.rdoFromRFile.TabStop = True - Me.rdoFromRFile.Text = "From R File:" - Me.rdoFromRFile.UseVisualStyleBackColor = True + Me.lblSaveText.AutoSize = True + Me.lblSaveText.Location = New System.Drawing.Point(299, 72) + Me.lblSaveText.Name = "lblSaveText" + Me.lblSaveText.Size = New System.Drawing.Size(116, 13) + Me.lblSaveText.TabIndex = 71 + Me.lblSaveText.Text = "(separated by commas)" + ' + 'lblSaveDataFrame + ' + Me.lblSaveDataFrame.AutoSize = True + Me.lblSaveDataFrame.Location = New System.Drawing.Point(64, 103) + Me.lblSaveDataFrame.Name = "lblSaveDataFrame" + Me.lblSaveDataFrame.Size = New System.Drawing.Size(65, 13) + Me.lblSaveDataFrame.TabIndex = 70 + Me.lblSaveDataFrame.Text = "Data Frame:" + ' + 'lblSaveColumn + ' + Me.lblSaveColumn.AutoSize = True + Me.lblSaveColumn.Location = New System.Drawing.Point(64, 72) + Me.lblSaveColumn.Name = "lblSaveColumn" + Me.lblSaveColumn.Size = New System.Drawing.Size(49, 13) + Me.lblSaveColumn.TabIndex = 69 + Me.lblSaveColumn.Text = "Name(s):" + ' + 'ucrInputDataframeColumn + ' + Me.ucrInputDataframeColumn.AddQuotesIfUnrecognised = True + Me.ucrInputDataframeColumn.AutoSize = True + Me.ucrInputDataframeColumn.IsMultiline = False + Me.ucrInputDataframeColumn.IsReadOnly = False + Me.ucrInputDataframeColumn.Location = New System.Drawing.Point(131, 103) + Me.ucrInputDataframeColumn.Margin = New System.Windows.Forms.Padding(9) + Me.ucrInputDataframeColumn.Name = "ucrInputDataframeColumn" + Me.ucrInputDataframeColumn.Size = New System.Drawing.Size(155, 21) + Me.ucrInputDataframeColumn.TabIndex = 68 + ' + 'ucrInputSaveColumn + ' + Me.ucrInputSaveColumn.AddQuotesIfUnrecognised = True + Me.ucrInputSaveColumn.AutoSize = True + Me.ucrInputSaveColumn.IsMultiline = False + Me.ucrInputSaveColumn.IsReadOnly = False + Me.ucrInputSaveColumn.Location = New System.Drawing.Point(132, 72) + Me.ucrInputSaveColumn.Margin = New System.Windows.Forms.Padding(9) + Me.ucrInputSaveColumn.Name = "ucrInputSaveColumn" + Me.ucrInputSaveColumn.Size = New System.Drawing.Size(154, 21) + Me.ucrInputSaveColumn.TabIndex = 67 + ' + 'rdoVariable + ' + Me.rdoVariable.AutoSize = True + Me.rdoVariable.Location = New System.Drawing.Point(49, 48) + Me.rdoVariable.Margin = New System.Windows.Forms.Padding(2) + Me.rdoVariable.Name = "rdoVariable" + Me.rdoVariable.Size = New System.Drawing.Size(92, 17) + Me.rdoVariable.TabIndex = 66 + Me.rdoVariable.TabStop = True + Me.rdoVariable.Text = "From Variable:" + Me.rdoVariable.UseVisualStyleBackColor = True ' 'rdoDataFrame ' Me.rdoDataFrame.AutoSize = True - Me.rdoDataFrame.Location = New System.Drawing.Point(48, 114) + Me.rdoDataFrame.Location = New System.Drawing.Point(48, 126) Me.rdoDataFrame.Margin = New System.Windows.Forms.Padding(2) Me.rdoDataFrame.Name = "rdoDataFrame" Me.rdoDataFrame.Size = New System.Drawing.Size(104, 17) @@ -195,7 +258,7 @@ Partial Class dlgScript ' Me.ucrChkSaveDataFrameSingle.AutoSize = True Me.ucrChkSaveDataFrameSingle.Checked = False - Me.ucrChkSaveDataFrameSingle.Location = New System.Drawing.Point(56, 167) + Me.ucrChkSaveDataFrameSingle.Location = New System.Drawing.Point(55, 174) Me.ucrChkSaveDataFrameSingle.Name = "ucrChkSaveDataFrameSingle" Me.ucrChkSaveDataFrameSingle.Size = New System.Drawing.Size(146, 23) Me.ucrChkSaveDataFrameSingle.TabIndex = 59 @@ -206,7 +269,7 @@ Partial Class dlgScript Me.ucrInputSaveDataFrame.AutoSize = True Me.ucrInputSaveDataFrame.IsMultiline = False Me.ucrInputSaveDataFrame.IsReadOnly = False - Me.ucrInputSaveDataFrame.Location = New System.Drawing.Point(57, 136) + Me.ucrInputSaveDataFrame.Location = New System.Drawing.Point(67, 147) Me.ucrInputSaveDataFrame.Margin = New System.Windows.Forms.Padding(9) Me.ucrInputSaveDataFrame.Name = "ucrInputSaveDataFrame" Me.ucrInputSaveDataFrame.Size = New System.Drawing.Size(145, 21) @@ -340,7 +403,7 @@ Partial Class dlgScript Me.ucrPnlSaveDataFrame.Location = New System.Drawing.Point(5, 48) Me.ucrPnlSaveDataFrame.Margin = New System.Windows.Forms.Padding(6) Me.ucrPnlSaveDataFrame.Name = "ucrPnlSaveDataFrame" - Me.ucrPnlSaveDataFrame.Size = New System.Drawing.Size(429, 134) + Me.ucrPnlSaveDataFrame.Size = New System.Drawing.Size(429, 208) Me.ucrPnlSaveDataFrame.TabIndex = 65 ' 'tbPageGetData @@ -360,7 +423,7 @@ Partial Class dlgScript Me.tbPageGetData.Location = New System.Drawing.Point(4, 22) Me.tbPageGetData.Name = "tbPageGetData" Me.tbPageGetData.Padding = New System.Windows.Forms.Padding(3) - Me.tbPageGetData.Size = New System.Drawing.Size(438, 245) + Me.tbPageGetData.Size = New System.Drawing.Size(438, 278) Me.tbPageGetData.TabIndex = 1 Me.tbPageGetData.Text = "Get Data" Me.tbPageGetData.UseVisualStyleBackColor = True @@ -540,7 +603,7 @@ Partial Class dlgScript Me.tbPageCommand.Controls.Add(Me.ucrPnlCommands) Me.tbPageCommand.Location = New System.Drawing.Point(4, 22) Me.tbPageCommand.Name = "tbPageCommand" - Me.tbPageCommand.Size = New System.Drawing.Size(438, 245) + Me.tbPageCommand.Size = New System.Drawing.Size(438, 278) Me.tbPageCommand.TabIndex = 3 Me.tbPageCommand.Text = "Commands" Me.tbPageCommand.UseVisualStyleBackColor = True @@ -790,7 +853,7 @@ Partial Class dlgScript Me.tbPageExamples.Controls.Add(Me.ucrCboExamplePackages) Me.tbPageExamples.Location = New System.Drawing.Point(4, 22) Me.tbPageExamples.Name = "tbPageExamples" - Me.tbPageExamples.Size = New System.Drawing.Size(438, 245) + Me.tbPageExamples.Size = New System.Drawing.Size(438, 278) Me.tbPageExamples.TabIndex = 4 Me.tbPageExamples.Text = "Library" Me.tbPageExamples.UseVisualStyleBackColor = True @@ -899,7 +962,7 @@ Partial Class dlgScript ' Me.lblPreview.AutoSize = True Me.lblPreview.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.lblPreview.Location = New System.Drawing.Point(9, 281) + Me.lblPreview.Location = New System.Drawing.Point(9, 314) Me.lblPreview.Name = "lblPreview" Me.lblPreview.Size = New System.Drawing.Size(48, 13) Me.lblPreview.TabIndex = 30 @@ -907,7 +970,7 @@ Partial Class dlgScript ' 'txtScript ' - Me.txtScript.Location = New System.Drawing.Point(5, 299) + Me.txtScript.Location = New System.Drawing.Point(5, 332) Me.txtScript.Multiline = True Me.txtScript.Name = "txtScript" Me.txtScript.ScrollBars = System.Windows.Forms.ScrollBars.Both @@ -918,81 +981,18 @@ Partial Class dlgScript ' Me.ucrBase.AutoSize = True Me.ucrBase.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrBase.Location = New System.Drawing.Point(6, 399) + Me.ucrBase.Location = New System.Drawing.Point(6, 431) Me.ucrBase.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5) Me.ucrBase.Name = "ucrBase" Me.ucrBase.Size = New System.Drawing.Size(408, 52) Me.ucrBase.TabIndex = 16 ' - 'rdoVariable - ' - Me.rdoVariable.AutoSize = True - Me.rdoVariable.Location = New System.Drawing.Point(49, 54) - Me.rdoVariable.Margin = New System.Windows.Forms.Padding(2) - Me.rdoVariable.Name = "rdoVariable" - Me.rdoVariable.Size = New System.Drawing.Size(92, 17) - Me.rdoVariable.TabIndex = 66 - Me.rdoVariable.TabStop = True - Me.rdoVariable.Text = "From Variable:" - Me.rdoVariable.UseVisualStyleBackColor = True - ' - 'ucrInputSaveColumn - ' - Me.ucrInputSaveColumn.AddQuotesIfUnrecognised = True - Me.ucrInputSaveColumn.AutoSize = True - Me.ucrInputSaveColumn.IsMultiline = False - Me.ucrInputSaveColumn.IsReadOnly = False - Me.ucrInputSaveColumn.Location = New System.Drawing.Point(207, 57) - Me.ucrInputSaveColumn.Margin = New System.Windows.Forms.Padding(9) - Me.ucrInputSaveColumn.Name = "ucrInputSaveColumn" - Me.ucrInputSaveColumn.Size = New System.Drawing.Size(105, 21) - Me.ucrInputSaveColumn.TabIndex = 67 - ' - 'ucrInputDataframeColumn - ' - Me.ucrInputDataframeColumn.AddQuotesIfUnrecognised = True - Me.ucrInputDataframeColumn.AutoSize = True - Me.ucrInputDataframeColumn.IsMultiline = False - Me.ucrInputDataframeColumn.IsReadOnly = False - Me.ucrInputDataframeColumn.Location = New System.Drawing.Point(206, 83) - Me.ucrInputDataframeColumn.Margin = New System.Windows.Forms.Padding(9) - Me.ucrInputDataframeColumn.Name = "ucrInputDataframeColumn" - Me.ucrInputDataframeColumn.Size = New System.Drawing.Size(106, 21) - Me.ucrInputDataframeColumn.TabIndex = 68 - ' - 'lblSaveColumn - ' - Me.lblSaveColumn.AutoSize = True - Me.lblSaveColumn.Location = New System.Drawing.Point(139, 57) - Me.lblSaveColumn.Name = "lblSaveColumn" - Me.lblSaveColumn.Size = New System.Drawing.Size(49, 13) - Me.lblSaveColumn.TabIndex = 69 - Me.lblSaveColumn.Text = "Name(s):" - ' - 'lblSaveDataFrame - ' - Me.lblSaveDataFrame.AutoSize = True - Me.lblSaveDataFrame.Location = New System.Drawing.Point(139, 83) - Me.lblSaveDataFrame.Name = "lblSaveDataFrame" - Me.lblSaveDataFrame.Size = New System.Drawing.Size(65, 13) - Me.lblSaveDataFrame.TabIndex = 70 - Me.lblSaveDataFrame.Text = "Data Frame:" - ' - 'lblSaveText - ' - Me.lblSaveText.AutoSize = True - Me.lblSaveText.Location = New System.Drawing.Point(317, 61) - Me.lblSaveText.Name = "lblSaveText" - Me.lblSaveText.Size = New System.Drawing.Size(116, 13) - Me.lblSaveText.TabIndex = 71 - Me.lblSaveText.Text = "(separated by commas)" - ' 'dlgScript ' Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi Me.AutoSize = True - Me.ClientSize = New System.Drawing.Size(458, 458) + Me.ClientSize = New System.Drawing.Size(458, 489) Me.Controls.Add(Me.txtScript) Me.Controls.Add(Me.lblPreview) Me.Controls.Add(Me.tbFeatures) diff --git a/instat/dlgScript.vb b/instat/dlgScript.vb index 39835aaab7..2f8f71f0b7 100644 --- a/instat/dlgScript.vb +++ b/instat/dlgScript.vb @@ -833,7 +833,7 @@ Public Class dlgScript clsImportRFunction.AddParameter(strParameterName:="data_tables", strParameterValue:=strDataFrameName) End If - strScript = "# Save variables " & """" & strColumneName & """" & "into data frame " & """" & strDataFrameName & """" & Environment.NewLine & strAssignedScript & clsImportRFunction.ToScript() + strScript = "# Save variables " & """" & strColumneName & """" & " into data frame " & """" & strDataFrameName & """" & Environment.NewLine & strAssignedScript & clsImportRFunction.ToScript() End If End If From cec5b51a6788d9f89685f05d0af2b781a1226a4b Mon Sep 17 00:00:00 2001 From: Derrick Agorhom <76208189+derekagorhom@users.noreply.github.com> Date: Mon, 20 Jan 2025 12:03:20 +0100 Subject: [PATCH 20/35] Code Changes --- instat/dlgScript.Designer.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instat/dlgScript.Designer.vb b/instat/dlgScript.Designer.vb index 9e5408b456..a5686b7ed2 100644 --- a/instat/dlgScript.Designer.vb +++ b/instat/dlgScript.Designer.vb @@ -227,10 +227,10 @@ Partial Class dlgScript Me.rdoVariable.Location = New System.Drawing.Point(49, 48) Me.rdoVariable.Margin = New System.Windows.Forms.Padding(2) Me.rdoVariable.Name = "rdoVariable" - Me.rdoVariable.Size = New System.Drawing.Size(92, 17) + Me.rdoVariable.Size = New System.Drawing.Size(97, 17) Me.rdoVariable.TabIndex = 66 Me.rdoVariable.TabStop = True - Me.rdoVariable.Text = "From Variable:" + Me.rdoVariable.Text = "From Variables:" Me.rdoVariable.UseVisualStyleBackColor = True ' 'rdoDataFrame From 4672a85f33128e70ada75947efd992a4c6f65a0d Mon Sep 17 00:00:00 2001 From: lilyclements Date: Mon, 20 Jan 2025 21:13:41 +0000 Subject: [PATCH 21/35] fixing calling year in crop_definitions --- instat/static/InstatObject/R/instat_object_R6.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index 53fe3b1ce7..727beb1321 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -2330,10 +2330,10 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r if (!missing(station)){ filtered_data <- filtered_data %>% - dplyr::group_by(station, year) + dplyr::group_by(.data[[station]], .data[[year]]) } else { filtered_data <- filtered_data %>% - dplyr::group_by(year) + dplyr::group_by(.data[[year]]) } filtered_data <- filtered_data %>% From cfefee590e15f73ffa80b9b414ca85ec91e31fe4 Mon Sep 17 00:00:00 2001 From: lilyclements Date: Tue, 21 Jan 2025 11:51:23 +0000 Subject: [PATCH 22/35] adding station into prop calculations --- .../static/InstatObject/R/instat_object_R6.R | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index 727beb1321..e704ed6b5b 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -2320,7 +2320,7 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r # we do this here to avoid calculating it multiple times. for (rain_i in rain_totals){ filtered_data <- filtered_data_1 %>% dplyr::mutate(rain_total = rain_i) %>% - dplyr::select(c(rain_total_name, plant_length_name, plant_day_name, everything())) + dplyr::select(c(rain_total_name, plant_length_name, plant_day_name, dplyr::everything())) # take the rows < 0 and run a check. We want to check # if (anyNA(rain_values) && sum_rain < data[[rain_total_name]][i]) { sum_rain <- NA @@ -2338,8 +2338,8 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r filtered_data <- filtered_data %>% # first add a column (T/F) that states that it is in the rainfall period or not. - dplyr::mutate(plant_day_cond = start_rain <= plant_day, - length_cond = plant_day + plant_length <= end_rains, + dplyr::mutate(plant_day_cond = start_day <= plant_day, + length_cond = plant_day + plant_length <= end_day, rain_cond = rain_i <= rain_total_actual) %>% dplyr::ungroup() @@ -2349,6 +2349,9 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r dplyr::mutate( overall_cond_with_start = plant_day_cond & length_cond & rain_cond, overall_cond_no_start = length_cond & rain_cond) + + if (!missing(station)) filtered_data <- filtered_data %>% dplyr::group_by(.data[[station]]) + proportion_data <- filtered_data %>% dplyr::summarise(prop_success_with_start = sum(overall_cond_with_start, na.rm = TRUE)/length(na.omit(overall_cond_with_start)), prop_success_no_start = sum(overall_cond_no_start, na.rm = TRUE)/length(na.omit(overall_cond_no_start))) @@ -2359,6 +2362,8 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r start_check == "yes" ~ plant_day_cond & length_cond & rain_cond, start_check == "no" ~ TRUE & length_cond & rain_cond) ) + + if (!missing(station)) filtered_data <- filtered_data %>% dplyr::group_by(.data[[station]]) proportion_data <- filtered_data %>% dplyr::summarise(prop_success = sum(overall_cond, na.rm = TRUE)/length(na.omit(overall_cond))) @@ -2394,8 +2399,8 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r self$import_data(data_tables = data_tables) } if (definition_props){ - prop_data_frame <- dplyr::bind_rows(proportion_df) %>% - dplyr::select(c(rain_total_name, plant_length_name, plant_day_name, everything())) + if (!missing(station)) prop_data_frame <- dplyr::bind_rows(proportion_df) %>% dplyr::select(c(station, rain_total_name, plant_length_name, plant_day_name, everything())) + else prop_data_frame <- dplyr::bind_rows(proportion_df) %>% dplyr::select(c(rain_total_name, plant_length_name, plant_day_name, everything())) prop_name <- "crop_prop" prop_name <- next_default_item(prefix = prop_name, existing_names = self$get_data_names(), include_index = FALSE) @@ -2404,7 +2409,7 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r self$import_data(data_tables = data_tables) # Add Link - if (return_crops_table) data_book$add_link(from_data_frame = crops_name, to_data_frame = prop_name, link_pairs=c(rain_total = rain_total_name, plant_length = plant_length_name, plant_day = plant_day_name), type="keyed_link") + #if (return_crops_table) data_book$add_link(from_data_frame = crops_name, to_data_frame = prop_name, link_pairs=c(rain_total = rain_total_name, plant_length = plant_length_name, plant_day = plant_day_name), type="keyed_link") if(print_table) { if (start_check %in% c("yes", "no")){ @@ -2430,9 +2435,9 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r prop_table_split_no_start <- split(prop_data_frame_no_start, f) # Create an empty list to store the merged data - print("Proportion with start check") + cat("Proportion with start check") print(prop_table_split_with_start) - print("Proportion without start check") + cat("Proportion without start check") print(prop_table_split_no_start) } } From 80d4ea9527d5623c7adc3cae18ec161c7a0def87 Mon Sep 17 00:00:00 2001 From: lilyclements Date: Tue, 21 Jan 2025 11:51:35 +0000 Subject: [PATCH 23/35] tidying code --- instat/static/InstatObject/R/instat_object_R6.R | 4 ---- 1 file changed, 4 deletions(-) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index e704ed6b5b..fbac1d87b1 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -2349,9 +2349,7 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r dplyr::mutate( overall_cond_with_start = plant_day_cond & length_cond & rain_cond, overall_cond_no_start = length_cond & rain_cond) - if (!missing(station)) filtered_data <- filtered_data %>% dplyr::group_by(.data[[station]]) - proportion_data <- filtered_data %>% dplyr::summarise(prop_success_with_start = sum(overall_cond_with_start, na.rm = TRUE)/length(na.omit(overall_cond_with_start)), prop_success_no_start = sum(overall_cond_no_start, na.rm = TRUE)/length(na.omit(overall_cond_no_start))) @@ -2362,9 +2360,7 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r start_check == "yes" ~ plant_day_cond & length_cond & rain_cond, start_check == "no" ~ TRUE & length_cond & rain_cond) ) - if (!missing(station)) filtered_data <- filtered_data %>% dplyr::group_by(.data[[station]]) - proportion_data <- filtered_data %>% dplyr::summarise(prop_success = sum(overall_cond, na.rm = TRUE)/length(na.omit(overall_cond))) } From 5084b6669bf02b4a80affa6e2e17ce7e2f1219c2 Mon Sep 17 00:00:00 2001 From: lilyclements Date: Tue, 21 Jan 2025 12:00:02 +0000 Subject: [PATCH 24/35] running print_table as return not print --- .../static/InstatObject/R/instat_object_R6.R | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index fbac1d87b1..9ceaadc739 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -2414,27 +2414,28 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r if(!missing(station)) f <- interaction(prop_table_unstacked[[station]], prop_table_unstacked[[plant_length_name]], lex.order = TRUE) else f <- prop_table_unstacked[[plant_length_name]] prop_table_split <- split(prop_table_unstacked, f) - print(prop_table_split) + return(prop_table_split) } else { - prop_data_frame_with_start <- prop_data_frame %>% - dplyr::select(-c("prop_success_no_start")) + prop_data_frame_with_start <- prop_data_frame %>% dplyr::select(-c("prop_success_no_start")) %>% dplyr::mutate(prop_success_with_start = round(prop_success_with_start, 2)) prop_data_frame_with_start <- reshape2::dcast(formula = as.formula(paste(if(!missing(station)) paste(station, "+"), plant_length_name, "+", rain_total_name, "~", plant_day_name)), data = prop_data_frame_with_start, value.var = "prop_success_with_start") if(!missing(station)) f <- interaction(prop_data_frame_with_start[[station]], prop_data_frame_with_start[[plant_length_name]], lex.order = TRUE) else f <- prop_data_frame_with_start[[plant_length_name]] prop_table_split_with_start <- split(prop_data_frame_with_start, f) - prop_data_frame_no_start <- prop_data_frame %>% - dplyr::select(-c("prop_success_with_start")) + prop_data_frame_no_start <- prop_data_frame %>% dplyr::select(-c("prop_success_with_start")) %>% dplyr::mutate(prop_success_no_start = round(prop_success_no_start, 2)) prop_data_frame_no_start <- reshape2::dcast(formula = as.formula(paste(if(!missing(station)) paste(station, "+"), plant_length_name, "+", rain_total_name, "~", plant_day_name)), data = prop_data_frame_no_start, value.var = "prop_success_no_start") if(!missing(station)) f <- interaction(prop_data_frame_no_start[[station]], prop_data_frame_no_start[[plant_length_name]], lex.order = TRUE) else f <- prop_data_frame_no_start[[plant_length_name]] prop_table_split_no_start <- split(prop_data_frame_no_start, f) - + # Create an empty list to store the merged data - cat("Proportion with start check") - print(prop_table_split_with_start) - cat("Proportion without start check") - print(prop_table_split_no_start) + merged_list <- list() + + # Vectorize the addition of source indicators and merging of data frames + prop_table_split_with_start <- lapply(prop_table_split_with_start, function(df) { + df$source <- 'with start' + return(df) + }) } } } From b762d95a65e0d232c9de3c1f79ece70c6c6ec770 Mon Sep 17 00:00:00 2001 From: lilyclements Date: Tue, 21 Jan 2025 12:59:59 +0000 Subject: [PATCH 25/35] removing print_table if statement --- .../static/InstatObject/R/instat_object_R6.R | 34 +++---------------- 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index 9ceaadc739..f49999ee92 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -2405,37 +2405,11 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r self$import_data(data_tables = data_tables) # Add Link - #if (return_crops_table) data_book$add_link(from_data_frame = crops_name, to_data_frame = prop_name, link_pairs=c(rain_total = rain_total_name, plant_length = plant_length_name, plant_day = plant_day_name), type="keyed_link") - - if(print_table) { - if (start_check %in% c("yes", "no")){ - prop_data_frame$prop_success <- round(prop_data_frame$prop_success, 2) - prop_table_unstacked <- reshape2::dcast(formula = as.formula(paste(if(!missing(station)) paste(station, "+"), plant_length_name, "+", rain_total_name, "~", plant_day_name)), data = prop_data_frame, value.var = "prop_success") - if(!missing(station)) f <- interaction(prop_table_unstacked[[station]], prop_table_unstacked[[plant_length_name]], lex.order = TRUE) - else f <- prop_table_unstacked[[plant_length_name]] - prop_table_split <- split(prop_table_unstacked, f) - return(prop_table_split) + if (return_crops_table){ + if (!missing(station)){ + self$add_link(from_data_frame = crops_name, to_data_frame = prop_name, link_pairs=c(station = station, rain_total = rain_total_name, plant_length = plant_length_name, plant_day = plant_day_name), type="keyed_link") } else { - prop_data_frame_with_start <- prop_data_frame %>% dplyr::select(-c("prop_success_no_start")) %>% dplyr::mutate(prop_success_with_start = round(prop_success_with_start, 2)) - prop_data_frame_with_start <- reshape2::dcast(formula = as.formula(paste(if(!missing(station)) paste(station, "+"), plant_length_name, "+", rain_total_name, "~", plant_day_name)), data = prop_data_frame_with_start, value.var = "prop_success_with_start") - if(!missing(station)) f <- interaction(prop_data_frame_with_start[[station]], prop_data_frame_with_start[[plant_length_name]], lex.order = TRUE) - else f <- prop_data_frame_with_start[[plant_length_name]] - prop_table_split_with_start <- split(prop_data_frame_with_start, f) - - prop_data_frame_no_start <- prop_data_frame %>% dplyr::select(-c("prop_success_with_start")) %>% dplyr::mutate(prop_success_no_start = round(prop_success_no_start, 2)) - prop_data_frame_no_start <- reshape2::dcast(formula = as.formula(paste(if(!missing(station)) paste(station, "+"), plant_length_name, "+", rain_total_name, "~", plant_day_name)), data = prop_data_frame_no_start, value.var = "prop_success_no_start") - if(!missing(station)) f <- interaction(prop_data_frame_no_start[[station]], prop_data_frame_no_start[[plant_length_name]], lex.order = TRUE) - else f <- prop_data_frame_no_start[[plant_length_name]] - prop_table_split_no_start <- split(prop_data_frame_no_start, f) - - # Create an empty list to store the merged data - merged_list <- list() - - # Vectorize the addition of source indicators and merging of data frames - prop_table_split_with_start <- lapply(prop_table_split_with_start, function(df) { - df$source <- 'with start' - return(df) - }) + self$add_link(from_data_frame = crops_name, to_data_frame = prop_name, link_pairs=c(rain_total = rain_total_name, plant_length = plant_length_name, plant_day = plant_day_name), type="keyed_link") } } } From ec2a132e65a13112ecf63df02058fd34528372ae Mon Sep 17 00:00:00 2001 From: lilyclements Date: Tue, 21 Jan 2025 13:00:30 +0000 Subject: [PATCH 26/35] adding note --- instat/static/InstatObject/R/instat_object_R6.R | 1 + 1 file changed, 1 insertion(+) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index f49999ee92..e5be6c5825 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -2216,6 +2216,7 @@ DataBook$set("public","get_variable_sets", function(data_name, set_names, force_ ) DataBook$set("public", "crops_definitions", function(data_name, year, station, rain, day, rain_totals, plant_days, plant_lengths, start_check = TRUE, season_data_name, start_day, end_day, return_crops_table = TRUE, definition_props = TRUE, print_table = TRUE){ + # Note "print_table" option is now deprecated and not in use. # Run checks is_station <- !missing(station) From 593128af91531915037109e1c6c87f9abcbd8ce8 Mon Sep 17 00:00:00 2001 From: Sophie Malla Tatchum Date: Tue, 21 Jan 2025 14:21:37 +0100 Subject: [PATCH 27/35] Added Climdex.Pcic package --- instat/dlgRPackages.vb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/instat/dlgRPackages.vb b/instat/dlgRPackages.vb index 488477f765..07b0595053 100644 --- a/instat/dlgRPackages.vb +++ b/instat/dlgRPackages.vb @@ -43,6 +43,7 @@ Public Class dlgInstallRPackage dctPackages.Add("rapidpror", Chr(34) & "rapidpror" & Chr(34)) dctPackages.Add("openappr", Chr(34) & "openappr" & Chr(34)) dctPackages.Add("networkGraphsR", Chr(34) & "networkGraphsR" & Chr(34)) + dctPackages.Add("climdex.pcic", Chr(34) & "climdex.pcic" & Chr(34)) ucrInputPackage.SetItems(dctPackages) ucrPnlRPackages.AddParameterValuesCondition(rdoCRAN, "checked", "cran") @@ -246,9 +247,19 @@ Public Class dlgInstallRPackage Private Sub ucrInputRepositoryName_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrInputRepositoryName.ControlValueChanged TestOkEnabled() GithubOption() + UseclimdexPackage() bUniqueChecked = False End Sub + Private Sub UseclimdexPackage() + If ucrInputPackage.GetText = "climdex.pcic" Then + ucrInputRepositoryName.SetText("pacificclimate") + Else + ucrInputRepositoryName.SetText("IDEMSInternational") + End If + + End Sub + Private Sub GithubOption() If Not (ucrInputPackage.IsEmpty AndAlso ucrInputRepositoryName.IsEmpty) Then clsRepositoryFunction.AddParameter("paste", Chr(34) & ucrInputRepositoryName.GetText & "/" & ucrInputPackage.GetText() & Chr(34), bIncludeArgumentName:=False) @@ -262,4 +273,8 @@ Public Class dlgInstallRPackage SetRCodeForControls(True) TestOkEnabled() End Sub + + Private Sub ucrInputPackage_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputPackage.ControlValueChanged + UseclimdexPackage() + End Sub End Class From 4f2e803a81eafc45245313f7ddd896ab91c5987c Mon Sep 17 00:00:00 2001 From: lilyclements Date: Tue, 21 Jan 2025 17:40:20 +0000 Subject: [PATCH 28/35] removing print_table option in dlg and R code --- instat/dlgPICSACrops.Designer.vb | 189 ++++++++++-------- instat/dlgPICSACrops.vb | 20 +- .../static/InstatObject/R/instat_object_R6.R | 3 +- 3 files changed, 112 insertions(+), 100 deletions(-) diff --git a/instat/dlgPICSACrops.Designer.vb b/instat/dlgPICSACrops.Designer.vb index e787f1db1b..d7db6283af 100644 --- a/instat/dlgPICSACrops.Designer.vb +++ b/instat/dlgPICSACrops.Designer.vb @@ -49,6 +49,7 @@ Partial Class dlgPICSACrops Me.ucrReceiverStart = New instat.ucrReceiverSingle() Me.ucrReceiverEnd = New instat.ucrReceiverSingle() Me.grpCropDefinitions = New System.Windows.Forms.GroupBox() + Me.lblStarts = New System.Windows.Forms.Label() Me.ucrInputCropLengths = New instat.ucrInputComboBox() Me.ucrInputWaterAmounts = New instat.ucrInputComboBox() Me.ucrInputPlantingDates = New instat.ucrInputComboBox() @@ -60,14 +61,13 @@ Partial Class dlgPICSACrops Me.lblWaterAmounts = New System.Windows.Forms.Label() Me.ucrPnlStartCheck = New instat.UcrPanel() Me.ucrChkDataProp = New instat.ucrCheck() - Me.ucrChkPrintDataProp = New instat.ucrCheck() + Me.ucrChkDataCrops = New instat.ucrCheck() Me.ucrReceiverRainfall = New instat.ucrReceiverSingle() Me.ucrReceiverDay = New instat.ucrReceiverSingle() Me.ucrReceiverYear = New instat.ucrReceiverSingle() Me.ucrReceiverStation = New instat.ucrReceiverSingle() Me.ucrSelectorForCrops = New instat.ucrSelectorByDataFrameAddRemove() Me.ucrBase = New instat.ucrButtons() - Me.lblStarts = New System.Windows.Forms.Label() Me.grpSeasonReceivers.SuspendLayout() Me.grpCropDefinitions.SuspendLayout() Me.SuspendLayout() @@ -75,9 +75,10 @@ Partial Class dlgPICSACrops 'lblSelectedSet ' Me.lblSelectedSet.AutoSize = True - Me.lblSelectedSet.Location = New System.Drawing.Point(232, 21) + Me.lblSelectedSet.Location = New System.Drawing.Point(348, 32) + Me.lblSelectedSet.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) Me.lblSelectedSet.Name = "lblSelectedSet" - Me.lblSelectedSet.Size = New System.Drawing.Size(43, 13) + Me.lblSelectedSet.Size = New System.Drawing.Size(64, 20) Me.lblSelectedSet.TabIndex = 15 Me.lblSelectedSet.Tag = "" Me.lblSelectedSet.Text = "Station:" @@ -85,9 +86,10 @@ Partial Class dlgPICSACrops 'Label2 ' Me.Label2.AutoSize = True - Me.Label2.Location = New System.Drawing.Point(365, 21) + Me.Label2.Location = New System.Drawing.Point(548, 32) + Me.Label2.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) Me.Label2.Name = "Label2" - Me.Label2.Size = New System.Drawing.Size(32, 13) + Me.Label2.Size = New System.Drawing.Size(47, 20) Me.Label2.TabIndex = 21 Me.Label2.Tag = "" Me.Label2.Text = "Year:" @@ -95,9 +97,10 @@ Partial Class dlgPICSACrops 'Label3 ' Me.Label3.AutoSize = True - Me.Label3.Location = New System.Drawing.Point(365, 66) + Me.Label3.Location = New System.Drawing.Point(548, 99) + Me.Label3.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) Me.Label3.Name = "Label3" - Me.Label3.Size = New System.Drawing.Size(65, 13) + Me.Label3.Size = New System.Drawing.Size(95, 20) Me.Label3.TabIndex = 22 Me.Label3.Tag = "" Me.Label3.Text = "Day in Year:" @@ -105,9 +108,10 @@ Partial Class dlgPICSACrops 'lblRain ' Me.lblRain.AutoSize = True - Me.lblRain.Location = New System.Drawing.Point(232, 66) + Me.lblRain.Location = New System.Drawing.Point(348, 99) + Me.lblRain.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) Me.lblRain.Name = "lblRain" - Me.lblRain.Size = New System.Drawing.Size(32, 13) + Me.lblRain.Size = New System.Drawing.Size(46, 20) Me.lblRain.TabIndex = 23 Me.lblRain.Tag = "" Me.lblRain.Text = "Rain:" @@ -115,9 +119,10 @@ Partial Class dlgPICSACrops 'Label5 ' Me.Label5.AutoSize = True - Me.Label5.Location = New System.Drawing.Point(6, 17) + Me.Label5.Location = New System.Drawing.Point(9, 26) + Me.Label5.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) Me.Label5.Name = "Label5" - Me.Label5.Size = New System.Drawing.Size(32, 13) + Me.Label5.Size = New System.Drawing.Size(48, 20) Me.Label5.TabIndex = 24 Me.Label5.Tag = "" Me.Label5.Text = "Start:" @@ -125,9 +130,10 @@ Partial Class dlgPICSACrops 'Label6 ' Me.Label6.AutoSize = True - Me.Label6.Location = New System.Drawing.Point(139, 19) + Me.Label6.Location = New System.Drawing.Point(208, 28) + Me.Label6.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) Me.Label6.Name = "Label6" - Me.Label6.Size = New System.Drawing.Size(32, 13) + Me.Label6.Size = New System.Drawing.Size(46, 20) Me.Label6.TabIndex = 25 Me.Label6.Tag = "" Me.Label6.Text = "End :" @@ -135,9 +141,10 @@ Partial Class dlgPICSACrops 'cmdOptions ' Me.cmdOptions.ImeMode = System.Windows.Forms.ImeMode.NoControl - Me.cmdOptions.Location = New System.Drawing.Point(368, 358) + Me.cmdOptions.Location = New System.Drawing.Point(552, 537) + Me.cmdOptions.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) Me.cmdOptions.Name = "cmdOptions" - Me.cmdOptions.Size = New System.Drawing.Size(120, 25) + Me.cmdOptions.Size = New System.Drawing.Size(180, 38) Me.cmdOptions.TabIndex = 31 Me.cmdOptions.Tag = "Options" Me.cmdOptions.Text = "Options" @@ -149,9 +156,11 @@ Partial Class dlgPICSACrops Me.grpSeasonReceivers.Controls.Add(Me.ucrReceiverStart) Me.grpSeasonReceivers.Controls.Add(Me.Label6) Me.grpSeasonReceivers.Controls.Add(Me.ucrReceiverEnd) - Me.grpSeasonReceivers.Location = New System.Drawing.Point(226, 111) + Me.grpSeasonReceivers.Location = New System.Drawing.Point(339, 166) + Me.grpSeasonReceivers.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) Me.grpSeasonReceivers.Name = "grpSeasonReceivers" - Me.grpSeasonReceivers.Size = New System.Drawing.Size(272, 66) + Me.grpSeasonReceivers.Padding = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.grpSeasonReceivers.Size = New System.Drawing.Size(408, 99) Me.grpSeasonReceivers.TabIndex = 38 Me.grpSeasonReceivers.TabStop = False Me.grpSeasonReceivers.Text = "Season Dates" @@ -160,11 +169,11 @@ Partial Class dlgPICSACrops ' Me.ucrReceiverStart.AutoSize = True Me.ucrReceiverStart.frmParent = Me - Me.ucrReceiverStart.Location = New System.Drawing.Point(10, 34) + Me.ucrReceiverStart.Location = New System.Drawing.Point(15, 51) Me.ucrReceiverStart.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverStart.Name = "ucrReceiverStart" Me.ucrReceiverStart.Selector = Nothing - Me.ucrReceiverStart.Size = New System.Drawing.Size(120, 20) + Me.ucrReceiverStart.Size = New System.Drawing.Size(180, 30) Me.ucrReceiverStart.strNcFilePath = "" Me.ucrReceiverStart.TabIndex = 19 Me.ucrReceiverStart.ucrSelector = Nothing @@ -173,11 +182,11 @@ Partial Class dlgPICSACrops ' Me.ucrReceiverEnd.AutoSize = True Me.ucrReceiverEnd.frmParent = Me - Me.ucrReceiverEnd.Location = New System.Drawing.Point(142, 34) + Me.ucrReceiverEnd.Location = New System.Drawing.Point(213, 51) Me.ucrReceiverEnd.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverEnd.Name = "ucrReceiverEnd" Me.ucrReceiverEnd.Selector = Nothing - Me.ucrReceiverEnd.Size = New System.Drawing.Size(120, 22) + Me.ucrReceiverEnd.Size = New System.Drawing.Size(180, 33) Me.ucrReceiverEnd.strNcFilePath = "" Me.ucrReceiverEnd.TabIndex = 26 Me.ucrReceiverEnd.ucrSelector = Nothing @@ -195,23 +204,35 @@ Partial Class dlgPICSACrops Me.grpCropDefinitions.Controls.Add(Me.lblCropLengthDays) Me.grpCropDefinitions.Controls.Add(Me.lblWaterAmounts) Me.grpCropDefinitions.Controls.Add(Me.ucrPnlStartCheck) - Me.grpCropDefinitions.Location = New System.Drawing.Point(6, 194) + Me.grpCropDefinitions.Location = New System.Drawing.Point(9, 291) + Me.grpCropDefinitions.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) Me.grpCropDefinitions.Name = "grpCropDefinitions" - Me.grpCropDefinitions.Size = New System.Drawing.Size(292, 158) + Me.grpCropDefinitions.Padding = New System.Windows.Forms.Padding(4, 4, 4, 4) + Me.grpCropDefinitions.Size = New System.Drawing.Size(438, 237) Me.grpCropDefinitions.TabIndex = 39 Me.grpCropDefinitions.TabStop = False Me.grpCropDefinitions.Text = "Crop Definitions" ' + 'lblStarts + ' + Me.lblStarts.AutoSize = True + Me.lblStarts.Location = New System.Drawing.Point(9, 40) + Me.lblStarts.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) + Me.lblStarts.Name = "lblStarts" + Me.lblStarts.Size = New System.Drawing.Size(104, 20) + Me.lblStarts.TabIndex = 56 + Me.lblStarts.Text = "Include Start:" + ' 'ucrInputCropLengths ' Me.ucrInputCropLengths.AddQuotesIfUnrecognised = True Me.ucrInputCropLengths.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink Me.ucrInputCropLengths.GetSetSelectedIndex = -1 Me.ucrInputCropLengths.IsReadOnly = False - Me.ucrInputCropLengths.Location = New System.Drawing.Point(106, 129) - Me.ucrInputCropLengths.Margin = New System.Windows.Forms.Padding(6) + Me.ucrInputCropLengths.Location = New System.Drawing.Point(159, 194) + Me.ucrInputCropLengths.Margin = New System.Windows.Forms.Padding(9, 9, 9, 9) Me.ucrInputCropLengths.Name = "ucrInputCropLengths" - Me.ucrInputCropLengths.Size = New System.Drawing.Size(170, 21) + Me.ucrInputCropLengths.Size = New System.Drawing.Size(255, 32) Me.ucrInputCropLengths.TabIndex = 55 ' 'ucrInputWaterAmounts @@ -220,10 +241,10 @@ Partial Class dlgPICSACrops Me.ucrInputWaterAmounts.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink Me.ucrInputWaterAmounts.GetSetSelectedIndex = -1 Me.ucrInputWaterAmounts.IsReadOnly = False - Me.ucrInputWaterAmounts.Location = New System.Drawing.Point(107, 92) - Me.ucrInputWaterAmounts.Margin = New System.Windows.Forms.Padding(9) + Me.ucrInputWaterAmounts.Location = New System.Drawing.Point(160, 138) + Me.ucrInputWaterAmounts.Margin = New System.Windows.Forms.Padding(14, 14, 14, 14) Me.ucrInputWaterAmounts.Name = "ucrInputWaterAmounts" - Me.ucrInputWaterAmounts.Size = New System.Drawing.Size(169, 21) + Me.ucrInputWaterAmounts.Size = New System.Drawing.Size(254, 32) Me.ucrInputWaterAmounts.TabIndex = 40 ' 'ucrInputPlantingDates @@ -232,19 +253,18 @@ Partial Class dlgPICSACrops Me.ucrInputPlantingDates.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink Me.ucrInputPlantingDates.GetSetSelectedIndex = -1 Me.ucrInputPlantingDates.IsReadOnly = False - Me.ucrInputPlantingDates.Location = New System.Drawing.Point(107, 58) - Me.ucrInputPlantingDates.Margin = New System.Windows.Forms.Padding(9) + Me.ucrInputPlantingDates.Location = New System.Drawing.Point(160, 87) + Me.ucrInputPlantingDates.Margin = New System.Windows.Forms.Padding(14, 14, 14, 14) Me.ucrInputPlantingDates.Name = "ucrInputPlantingDates" - Me.ucrInputPlantingDates.Size = New System.Drawing.Size(169, 21) + Me.ucrInputPlantingDates.Size = New System.Drawing.Size(254, 32) Me.ucrInputPlantingDates.TabIndex = 53 ' 'rdoBoth ' Me.rdoBoth.AutoSize = True - Me.rdoBoth.Location = New System.Drawing.Point(225, 25) - Me.rdoBoth.Margin = New System.Windows.Forms.Padding(2) + Me.rdoBoth.Location = New System.Drawing.Point(338, 38) Me.rdoBoth.Name = "rdoBoth" - Me.rdoBoth.Size = New System.Drawing.Size(47, 17) + Me.rdoBoth.Size = New System.Drawing.Size(68, 24) Me.rdoBoth.TabIndex = 44 Me.rdoBoth.TabStop = True Me.rdoBoth.Text = "Both" @@ -253,10 +273,9 @@ Partial Class dlgPICSACrops 'rdoNo ' Me.rdoNo.AutoSize = True - Me.rdoNo.Location = New System.Drawing.Point(153, 25) - Me.rdoNo.Margin = New System.Windows.Forms.Padding(2) + Me.rdoNo.Location = New System.Drawing.Point(230, 38) Me.rdoNo.Name = "rdoNo" - Me.rdoNo.Size = New System.Drawing.Size(39, 17) + Me.rdoNo.Size = New System.Drawing.Size(54, 24) Me.rdoNo.TabIndex = 45 Me.rdoNo.TabStop = True Me.rdoNo.Text = "No" @@ -265,10 +284,9 @@ Partial Class dlgPICSACrops 'rdoYes ' Me.rdoYes.AutoSize = True - Me.rdoYes.Location = New System.Drawing.Point(81, 25) - Me.rdoYes.Margin = New System.Windows.Forms.Padding(2) + Me.rdoYes.Location = New System.Drawing.Point(122, 38) Me.rdoYes.Name = "rdoYes" - Me.rdoYes.Size = New System.Drawing.Size(43, 17) + Me.rdoYes.Size = New System.Drawing.Size(62, 24) Me.rdoYes.TabIndex = 43 Me.rdoYes.TabStop = True Me.rdoYes.Text = "Yes" @@ -277,68 +295,71 @@ Partial Class dlgPICSACrops 'lblPlantingDays ' Me.lblPlantingDays.AutoSize = True - Me.lblPlantingDays.Location = New System.Drawing.Point(3, 60) + Me.lblPlantingDays.Location = New System.Drawing.Point(4, 90) + Me.lblPlantingDays.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) Me.lblPlantingDays.Name = "lblPlantingDays" - Me.lblPlantingDays.Size = New System.Drawing.Size(81, 13) + Me.lblPlantingDays.Size = New System.Drawing.Size(120, 20) Me.lblPlantingDays.TabIndex = 42 Me.lblPlantingDays.Text = "Planting Day(s):" ' 'lblCropLengthDays ' Me.lblCropLengthDays.AutoSize = True - Me.lblCropLengthDays.Location = New System.Drawing.Point(5, 133) + Me.lblCropLengthDays.Location = New System.Drawing.Point(8, 200) + Me.lblCropLengthDays.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) Me.lblCropLengthDays.Name = "lblCropLengthDays" - Me.lblCropLengthDays.Size = New System.Drawing.Size(101, 13) + Me.lblCropLengthDays.Size = New System.Drawing.Size(151, 20) Me.lblCropLengthDays.TabIndex = 41 Me.lblCropLengthDays.Text = "Crop Length Day(s):" ' 'lblWaterAmounts ' Me.lblWaterAmounts.AutoSize = True - Me.lblWaterAmounts.Location = New System.Drawing.Point(5, 95) + Me.lblWaterAmounts.Location = New System.Drawing.Point(8, 142) + Me.lblWaterAmounts.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0) Me.lblWaterAmounts.Name = "lblWaterAmounts" - Me.lblWaterAmounts.Size = New System.Drawing.Size(89, 13) + Me.lblWaterAmounts.Size = New System.Drawing.Size(134, 20) Me.lblWaterAmounts.TabIndex = 40 Me.lblWaterAmounts.Text = "Water Amount(s):" ' 'ucrPnlStartCheck ' Me.ucrPnlStartCheck.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrPnlStartCheck.Location = New System.Drawing.Point(75, 14) - Me.ucrPnlStartCheck.Margin = New System.Windows.Forms.Padding(6) + Me.ucrPnlStartCheck.Location = New System.Drawing.Point(112, 21) + Me.ucrPnlStartCheck.Margin = New System.Windows.Forms.Padding(9, 9, 9, 9) Me.ucrPnlStartCheck.Name = "ucrPnlStartCheck" - Me.ucrPnlStartCheck.Size = New System.Drawing.Size(201, 37) + Me.ucrPnlStartCheck.Size = New System.Drawing.Size(302, 56) Me.ucrPnlStartCheck.TabIndex = 46 ' 'ucrChkDataProp ' Me.ucrChkDataProp.AutoSize = True Me.ucrChkDataProp.Checked = False - Me.ucrChkDataProp.Location = New System.Drawing.Point(10, 358) - Me.ucrChkDataProp.Margin = New System.Windows.Forms.Padding(6) + Me.ucrChkDataProp.Location = New System.Drawing.Point(281, 539) + Me.ucrChkDataProp.Margin = New System.Windows.Forms.Padding(9, 9, 9, 9) Me.ucrChkDataProp.Name = "ucrChkDataProp" - Me.ucrChkDataProp.Size = New System.Drawing.Size(172, 23) + Me.ucrChkDataProp.Size = New System.Drawing.Size(258, 34) Me.ucrChkDataProp.TabIndex = 37 ' - 'ucrChkPrintDataProp + 'ucrChkDataCrops ' - Me.ucrChkPrintDataProp.AutoSize = True - Me.ucrChkPrintDataProp.Checked = False - Me.ucrChkPrintDataProp.Location = New System.Drawing.Point(188, 358) - Me.ucrChkPrintDataProp.Margin = New System.Windows.Forms.Padding(6) - Me.ucrChkPrintDataProp.Name = "ucrChkPrintDataProp" - Me.ucrChkPrintDataProp.Size = New System.Drawing.Size(255, 23) - Me.ucrChkPrintDataProp.TabIndex = 36 + Me.ucrChkDataCrops.AutoSize = True + Me.ucrChkDataCrops.Checked = False + Me.ucrChkDataCrops.Location = New System.Drawing.Point(9, 539) + Me.ucrChkDataCrops.Margin = New System.Windows.Forms.Padding(9, 9, 9, 9) + Me.ucrChkDataCrops.Name = "ucrChkDataCrops" + Me.ucrChkDataCrops.Size = New System.Drawing.Size(382, 34) + Me.ucrChkDataCrops.TabIndex = 36 ' 'ucrReceiverRainfall ' Me.ucrReceiverRainfall.AutoSize = True Me.ucrReceiverRainfall.frmParent = Me - Me.ucrReceiverRainfall.Location = New System.Drawing.Point(236, 81) + Me.ucrReceiverRainfall.Location = New System.Drawing.Point(354, 122) Me.ucrReceiverRainfall.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverRainfall.Name = "ucrReceiverRainfall" Me.ucrReceiverRainfall.Selector = Nothing - Me.ucrReceiverRainfall.Size = New System.Drawing.Size(120, 20) + Me.ucrReceiverRainfall.Size = New System.Drawing.Size(180, 30) Me.ucrReceiverRainfall.strNcFilePath = "" Me.ucrReceiverRainfall.TabIndex = 17 Me.ucrReceiverRainfall.ucrSelector = Nothing @@ -347,11 +368,11 @@ Partial Class dlgPICSACrops ' Me.ucrReceiverDay.AutoSize = True Me.ucrReceiverDay.frmParent = Me - Me.ucrReceiverDay.Location = New System.Drawing.Point(368, 81) + Me.ucrReceiverDay.Location = New System.Drawing.Point(552, 122) Me.ucrReceiverDay.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverDay.Name = "ucrReceiverDay" Me.ucrReceiverDay.Selector = Nothing - Me.ucrReceiverDay.Size = New System.Drawing.Size(120, 20) + Me.ucrReceiverDay.Size = New System.Drawing.Size(180, 30) Me.ucrReceiverDay.strNcFilePath = "" Me.ucrReceiverDay.TabIndex = 16 Me.ucrReceiverDay.ucrSelector = Nothing @@ -360,11 +381,11 @@ Partial Class dlgPICSACrops ' Me.ucrReceiverYear.AutoSize = True Me.ucrReceiverYear.frmParent = Me - Me.ucrReceiverYear.Location = New System.Drawing.Point(368, 37) + Me.ucrReceiverYear.Location = New System.Drawing.Point(552, 56) Me.ucrReceiverYear.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverYear.Name = "ucrReceiverYear" Me.ucrReceiverYear.Selector = Nothing - Me.ucrReceiverYear.Size = New System.Drawing.Size(120, 20) + Me.ucrReceiverYear.Size = New System.Drawing.Size(180, 30) Me.ucrReceiverYear.strNcFilePath = "" Me.ucrReceiverYear.TabIndex = 3 Me.ucrReceiverYear.ucrSelector = Nothing @@ -373,11 +394,11 @@ Partial Class dlgPICSACrops ' Me.ucrReceiverStation.AutoSize = True Me.ucrReceiverStation.frmParent = Me - Me.ucrReceiverStation.Location = New System.Drawing.Point(236, 37) + Me.ucrReceiverStation.Location = New System.Drawing.Point(354, 56) Me.ucrReceiverStation.Margin = New System.Windows.Forms.Padding(0) Me.ucrReceiverStation.Name = "ucrReceiverStation" Me.ucrReceiverStation.Selector = Nothing - Me.ucrReceiverStation.Size = New System.Drawing.Size(120, 20) + Me.ucrReceiverStation.Size = New System.Drawing.Size(180, 30) Me.ucrReceiverStation.strNcFilePath = "" Me.ucrReceiverStation.TabIndex = 2 Me.ucrReceiverStation.ucrSelector = Nothing @@ -388,41 +409,32 @@ Partial Class dlgPICSACrops Me.ucrSelectorForCrops.bDropUnusedFilterLevels = False Me.ucrSelectorForCrops.bShowHiddenColumns = False Me.ucrSelectorForCrops.bUseCurrentFilter = True - Me.ucrSelectorForCrops.Location = New System.Drawing.Point(6, 5) + Me.ucrSelectorForCrops.Location = New System.Drawing.Point(9, 8) Me.ucrSelectorForCrops.Margin = New System.Windows.Forms.Padding(0) Me.ucrSelectorForCrops.Name = "ucrSelectorForCrops" - Me.ucrSelectorForCrops.Size = New System.Drawing.Size(213, 183) + Me.ucrSelectorForCrops.Size = New System.Drawing.Size(320, 274) Me.ucrSelectorForCrops.TabIndex = 1 ' 'ucrBase ' Me.ucrBase.AutoSize = True Me.ucrBase.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink - Me.ucrBase.Location = New System.Drawing.Point(10, 392) - Me.ucrBase.Margin = New System.Windows.Forms.Padding(4) + Me.ucrBase.Location = New System.Drawing.Point(15, 588) + Me.ucrBase.Margin = New System.Windows.Forms.Padding(6, 6, 6, 6) Me.ucrBase.Name = "ucrBase" - Me.ucrBase.Size = New System.Drawing.Size(408, 52) + Me.ucrBase.Size = New System.Drawing.Size(611, 77) Me.ucrBase.TabIndex = 0 ' - 'lblStarts - ' - Me.lblStarts.AutoSize = True - Me.lblStarts.Location = New System.Drawing.Point(6, 27) - Me.lblStarts.Name = "lblStarts" - Me.lblStarts.Size = New System.Drawing.Size(70, 13) - Me.lblStarts.TabIndex = 56 - Me.lblStarts.Text = "Include Start:" - ' 'dlgPICSACrops ' - Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) + Me.AutoScaleDimensions = New System.Drawing.SizeF(144.0!, 144.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi Me.AutoSize = True - Me.ClientSize = New System.Drawing.Size(504, 449) + Me.ClientSize = New System.Drawing.Size(756, 674) Me.Controls.Add(Me.grpCropDefinitions) Me.Controls.Add(Me.grpSeasonReceivers) Me.Controls.Add(Me.ucrChkDataProp) - Me.Controls.Add(Me.ucrChkPrintDataProp) + Me.Controls.Add(Me.ucrChkDataCrops) Me.Controls.Add(Me.cmdOptions) Me.Controls.Add(Me.lblRain) Me.Controls.Add(Me.Label3) @@ -435,6 +447,7 @@ Partial Class dlgPICSACrops Me.Controls.Add(Me.ucrSelectorForCrops) Me.Controls.Add(Me.ucrBase) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow + Me.Margin = New System.Windows.Forms.Padding(4, 4, 4, 4) Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "dlgPICSACrops" @@ -464,7 +477,7 @@ Partial Class dlgPICSACrops Friend WithEvents Label5 As Label Friend WithEvents lblRain As Label Friend WithEvents cmdOptions As Button - Friend WithEvents ucrChkPrintDataProp As ucrCheck + Friend WithEvents ucrChkDataCrops As ucrCheck Friend WithEvents ucrChkDataProp As ucrCheck Friend WithEvents grpSeasonReceivers As GroupBox Friend WithEvents grpCropDefinitions As GroupBox diff --git a/instat/dlgPICSACrops.vb b/instat/dlgPICSACrops.vb index a340b3716c..5ef3b22f51 100644 --- a/instat/dlgPICSACrops.vb +++ b/instat/dlgPICSACrops.vb @@ -169,16 +169,16 @@ Public Class dlgPICSACrops 'ucrNudWaterSeqStep.SetParameter(New RParameter("step", clsSeqRainfall)) 'ucrNudWaterSeqTo.SetParameter(New RParameter("to", clsSeqRainfall)) + ucrChkDataCrops.SetText("Return Crops Data") + ucrChkDataCrops.SetParameter(New RParameter("return_crops_table", 11), bNewChangeParameterValue:=True, strNewValueIfChecked:="TRUE", strNewValueIfUnchecked:="FALSE") + ucrChkDataCrops.SetRDefault("TRUE") + ucrChkDataProp.SetText("Calculate Proportions") - ucrChkDataProp.SetParameter(New RParameter("definition_props", 8), bNewChangeParameterValue:=True, strNewValueIfChecked:="TRUE", strNewValueIfUnchecked:="FALSE") + ucrChkDataProp.SetParameter(New RParameter("definition_props", 12), bNewChangeParameterValue:=True, strNewValueIfChecked:="TRUE", strNewValueIfUnchecked:="FALSE") ucrChkDataProp.SetRDefault("TRUE") - ucrChkPrintDataProp.SetText("Print Proportions Table(s)") - ucrChkPrintDataProp.SetParameter(New RParameter("print_table", 9), bNewChangeParameterValue:=True, strNewValueIfChecked:="TRUE", strNewValueIfUnchecked:="FALSE") - ucrChkPrintDataProp.SetRDefault("TRUE") - 'Linking of controls - ucrChkDataProp.AddToLinkedControls(ucrChkPrintDataProp, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedDisabledIfParameterMissing:=True) + ucrChkDataProp.AddToLinkedControls(ucrChkDataCrops, {True}, bNewLinkedAddRemoveParameter:=True, bNewLinkedDisabledIfParameterMissing:=True) End Sub Private Sub SetDefaults() @@ -206,8 +206,8 @@ Public Class dlgPICSACrops ucrInputPlantingDates.SetName("160") ucrInputCropLengths.SetName("120") ucrInputWaterAmounts.SetName("600") - clsCropsFunction.AddParameter("definition_props", "TRUE", iPosition:=11) - clsCropsFunction.AddParameter("print_table", "TRUE", iPosition:=12) + clsCropsFunction.AddParameter("return_crops_table", "TRUE", iPosition:=11) + clsCropsFunction.AddParameter("definition_props", "TRUE", iPosition:=12) ucrBase.clsRsyntax.SetBaseRFunction(clsCropsFunction) ucrBase.clsRsyntax.iCallType = 2 TestOkEnabled() @@ -232,7 +232,7 @@ Public Class dlgPICSACrops ' Disabled as list validation not working correctly with reading/writing controls ucrChkDataProp.SetRCode(clsCropsFunction, bReset) - ucrChkPrintDataProp.SetRCode(clsCropsFunction, bReset) + ucrChkDataCrops.SetRCode(clsCropsFunction, bReset) If bReset Then ucrPnlStartCheck.SetRCode(clsDummyFunction, bReset) End If @@ -246,7 +246,7 @@ Public Class dlgPICSACrops End Sub Private Sub TestOkEnabled() - If Not ucrReceiverYear.IsEmpty AndAlso Not ucrReceiverRainfall.IsEmpty AndAlso Not ucrReceiverStart.IsEmpty AndAlso Not ucrReceiverDay.IsEmpty AndAlso Not ucrReceiverEnd.IsEmpty AndAlso Not ucrInputPlantingDates.IsEmpty AndAlso Not ucrInputCropLengths.IsEmpty AndAlso Not ucrInputWaterAmounts.IsEmpty Then + If Not ucrReceiverYear.IsEmpty AndAlso Not ucrReceiverRainfall.IsEmpty AndAlso Not ucrReceiverStart.IsEmpty AndAlso Not ucrReceiverDay.IsEmpty AndAlso Not ucrReceiverEnd.IsEmpty AndAlso Not ucrInputPlantingDates.IsEmpty AndAlso Not ucrInputCropLengths.IsEmpty AndAlso Not ucrInputWaterAmounts.IsEmpty AndAlso (ucrChkDataCrops.Checked OrElse ucrChkDataProp.Checked) Then ucrBase.OKEnabled(True) Else ucrBase.OKEnabled(False) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index e5be6c5825..64f4d4d367 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -2215,8 +2215,7 @@ DataBook$set("public","get_variable_sets", function(data_name, set_names, force_ } ) -DataBook$set("public", "crops_definitions", function(data_name, year, station, rain, day, rain_totals, plant_days, plant_lengths, start_check = TRUE, season_data_name, start_day, end_day, return_crops_table = TRUE, definition_props = TRUE, print_table = TRUE){ - # Note "print_table" option is now deprecated and not in use. +DataBook$set("public", "crops_definitions", function(data_name, year, station, rain, day, rain_totals, plant_days, plant_lengths, start_check = TRUE, season_data_name, start_day, end_day, return_crops_table = TRUE, definition_props = TRUE){ # Run checks is_station <- !missing(station) From 4ca07e104eee7ef307e07b5b8020ec5bb0be737b Mon Sep 17 00:00:00 2001 From: lilyclements Date: Tue, 21 Jan 2025 18:07:55 +0000 Subject: [PATCH 29/35] fixing outputted column order --- .../static/InstatObject/R/instat_object_R6.R | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index 64f4d4d367..7b22d9f95b 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -2271,9 +2271,7 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r i <- 1 calculate_rain_condition <- function(data){ - data <- data %>% - dplyr::select(-rain_total_name) %>% - unique() + data <- data %>% dplyr::select(-rain_total_name) %>% unique() for (i in 1:nrow(data)) { # Create a condition to filter the daily data based on the year, day, and plant day/length @@ -2319,8 +2317,7 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r # we now split by our different rain_total_actual conditions. # we do this here to avoid calculating it multiple times. for (rain_i in rain_totals){ - filtered_data <- filtered_data_1 %>% dplyr::mutate(rain_total = rain_i) %>% - dplyr::select(c(rain_total_name, plant_length_name, plant_day_name, dplyr::everything())) + filtered_data <- filtered_data_1 %>% dplyr::mutate(rain_total = rain_i) # take the rows < 0 and run a check. We want to check # if (anyNA(rain_values) && sum_rain < data[[rain_total_name]][i]) { sum_rain <- NA @@ -2328,19 +2325,16 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r filtered_data <- filtered_data %>% dplyr::mutate(rain_total_actual = ifelse(rain_total_actual < 0, ifelse(-1*rain_total_actual < rain_total, NA, -1*rain_total_actual), rain_total_actual)) - if (!missing(station)){ - filtered_data <- filtered_data %>% - dplyr::group_by(.data[[station]], .data[[year]]) - } else { - filtered_data <- filtered_data %>% - dplyr::group_by(.data[[year]]) - } + if (!missing(station)) filtered_data <- filtered_data %>% dplyr::group_by(.data[[station]], .data[[year]]) + else filtered_data <- filtered_data %>% dplyr::group_by(.data[[year]]) + #return(filtered_data) + filtered_data <- filtered_data %>% # first add a column (T/F) that states that it is in the rainfall period or not. - dplyr::mutate(plant_day_cond = start_day <= plant_day, - length_cond = plant_day + plant_length <= end_day, - rain_cond = rain_i <= rain_total_actual) %>% + dplyr::mutate(plant_day_cond = .data[[start_day]] <= plant_day, + length_cond = plant_day + plant_length <= .data[[end_day]], + rain_cond = rain_i <= rain_total_actual) %>% dplyr::ungroup() if (start_check == "both"){ @@ -2380,9 +2374,12 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r } } + if (!missing(station)) column_order <- c(station, plant_day_name, plant_length_name, rain_total_name) + else column_order <- c(plant_day_name, plant_length_name, rain_total_name) + if (return_crops_table){ # here we get crop_def and import it as a new DF - crops_def_table <- dplyr::bind_rows(crops_def_table) + crops_def_table <- dplyr::bind_rows(crops_def_table) %>% dplyr::select(c(all_of(column_order), everything())) %>% dplyr::arrange(dplyr::across(dplyr::all_of(column_order))) crops_name <- "crop_def" crops_name <- next_default_item(prefix = crops_name, existing_names = self$get_data_names(), include_index = FALSE) data_tables <- list(crops_def_table) @@ -2395,9 +2392,8 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r self$import_data(data_tables = data_tables) } if (definition_props){ - if (!missing(station)) prop_data_frame <- dplyr::bind_rows(proportion_df) %>% dplyr::select(c(station, rain_total_name, plant_length_name, plant_day_name, everything())) - else prop_data_frame <- dplyr::bind_rows(proportion_df) %>% dplyr::select(c(rain_total_name, plant_length_name, plant_day_name, everything())) - + prop_data_frame <- dplyr::bind_rows(proportion_df) %>% dplyr::select(c(all_of(column_order), everything())) %>% dplyr::arrange(dplyr::across(dplyr::all_of(column_order))) + prop_name <- "crop_prop" prop_name <- next_default_item(prefix = prop_name, existing_names = self$get_data_names(), include_index = FALSE) data_tables <- list(prop_data_frame) From bdce50a8fe4bc599fdaed42c1f2cb5c71681e5a2 Mon Sep 17 00:00:00 2001 From: lilyclements Date: Tue, 21 Jan 2025 18:08:16 +0000 Subject: [PATCH 30/35] remove comment --- instat/static/InstatObject/R/instat_object_R6.R | 2 -- 1 file changed, 2 deletions(-) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index 7b22d9f95b..8ed1f14750 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -2327,8 +2327,6 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r if (!missing(station)) filtered_data <- filtered_data %>% dplyr::group_by(.data[[station]], .data[[year]]) else filtered_data <- filtered_data %>% dplyr::group_by(.data[[year]]) - - #return(filtered_data) filtered_data <- filtered_data %>% # first add a column (T/F) that states that it is in the rainfall period or not. From 306a6adcf1ac35fc56f09c7e809c68807a771b68 Mon Sep 17 00:00:00 2001 From: lilyclements Date: Tue, 21 Jan 2025 18:27:01 +0000 Subject: [PATCH 31/35] match.arg check --- instat/static/InstatObject/R/instat_object_R6.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index 8ed1f14750..9e5b443cc1 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -2215,9 +2215,10 @@ DataBook$set("public","get_variable_sets", function(data_name, set_names, force_ } ) -DataBook$set("public", "crops_definitions", function(data_name, year, station, rain, day, rain_totals, plant_days, plant_lengths, start_check = TRUE, season_data_name, start_day, end_day, return_crops_table = TRUE, definition_props = TRUE){ +DataBook$set("public", "crops_definitions", function(data_name, year, station, rain, day, rain_totals, plant_days, plant_lengths, start_check = c("both", "yes", "no"), season_data_name, start_day, end_day, return_crops_table = TRUE, definition_props = TRUE){ # Run checks is_station <- !missing(station) + start_check <- match.arg(start_check) if(missing(year)) stop("Year column must be specified.") if(!is_station) by <- year From 285f04588184c66a814fba08b7e9937d990c893a Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Wed, 22 Jan 2025 09:57:31 +0300 Subject: [PATCH 32/35] resolving comments --- instat/static/InstatObject/R/data_object_R6.R | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/instat/static/InstatObject/R/data_object_R6.R b/instat/static/InstatObject/R/data_object_R6.R index 8287333e2e..4183798f63 100644 --- a/instat/static/InstatObject/R/data_object_R6.R +++ b/instat/static/InstatObject/R/data_object_R6.R @@ -922,12 +922,8 @@ DataSheet$set("public", "cor", function(x_col_names, y_col_name, use = "everythi ) DataSheet$set("public", "update_selection", function(new_values, column_selection_name = NULL) { - if(missing(new_values)) stop("new_values is required") - - # Find the column selection to update - if (is.null(column_selection_name)) { - stop("A column selection name must be provided to update the selection.") - } + if (missing(new_values)) stop("new_values is required") + if (missing(column_selection_name)) stop("column_selection_name is required") column_selection_obj <- private$column_selections[[column_selection_name]] @@ -993,7 +989,7 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne column_names <- self$get_column_names() - if (any(is.na(column_names))) { + if (anyNA(column_names)) { column_names[is.na(column_names)] <- new_col_name } else { column_names <- new_col_name @@ -1028,7 +1024,7 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne column_names <- self$get_column_names() - if (any(is.na(column_names))) { + if (anyNA(column_names)) { column_names[is.na(column_names)] <- new_col_names } else { column_names <- new_col_names @@ -1036,7 +1032,6 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne self$update_selection(column_names, private$.current_column_selection$name) - if(self$column_selection_applied()) self$remove_current_column_selection() if(any(c("sfc", "sfc_MULTIPOLYGON") %in% class(private$dataprivate$data)[cols_changed_index])){ # Update the geometry column reference sf::st_geometry(private$data) <- new_col_names @@ -1068,7 +1063,6 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne .cols = {{ .cols }}, ... ) - if(self$column_selection_applied()) self$remove_current_column_selection() new_col_names <- names(private$data) if (!all(new_col_names %in% curr_col_names)) { new_col_names <- new_col_names[!(new_col_names %in% curr_col_names)] @@ -1077,7 +1071,7 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne } column_names <- self$get_column_names() - if (any(is.na(column_names))) { + if (anyNA(column_names)) { column_names[is.na(column_names)] <- new_col_names } else { column_names <- new_col_names From 6cbd9b886371e06758be747ae7f5d0e9e6cbec3a Mon Sep 17 00:00:00 2001 From: Sophie Malla Tatchum Date: Wed, 22 Jan 2025 09:13:14 +0100 Subject: [PATCH 33/35] Change made --- instat/dlgRPackages.vb | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/instat/dlgRPackages.vb b/instat/dlgRPackages.vb index 07b0595053..31635f28e9 100644 --- a/instat/dlgRPackages.vb +++ b/instat/dlgRPackages.vb @@ -247,19 +247,9 @@ Public Class dlgInstallRPackage Private Sub ucrInputRepositoryName_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrInputRepositoryName.ControlValueChanged TestOkEnabled() GithubOption() - UseclimdexPackage() bUniqueChecked = False End Sub - Private Sub UseclimdexPackage() - If ucrInputPackage.GetText = "climdex.pcic" Then - ucrInputRepositoryName.SetText("pacificclimate") - Else - ucrInputRepositoryName.SetText("IDEMSInternational") - End If - - End Sub - Private Sub GithubOption() If Not (ucrInputPackage.IsEmpty AndAlso ucrInputRepositoryName.IsEmpty) Then clsRepositoryFunction.AddParameter("paste", Chr(34) & ucrInputRepositoryName.GetText & "/" & ucrInputPackage.GetText() & Chr(34), bIncludeArgumentName:=False) @@ -273,8 +263,4 @@ Public Class dlgInstallRPackage SetRCodeForControls(True) TestOkEnabled() End Sub - - Private Sub ucrInputPackage_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrInputPackage.ControlValueChanged - UseclimdexPackage() - End Sub End Class From 6f2ace5af369a9d8b6b632fa16ee9025fa860f6f Mon Sep 17 00:00:00 2001 From: lilyclements Date: Wed, 22 Jan 2025 13:17:00 +0000 Subject: [PATCH 34/35] adding check for all NA values --- .../static/InstatObject/R/instat_object_R6.R | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/instat/static/InstatObject/R/instat_object_R6.R b/instat/static/InstatObject/R/instat_object_R6.R index 9e5b443cc1..98e0063279 100644 --- a/instat/static/InstatObject/R/instat_object_R6.R +++ b/instat/static/InstatObject/R/instat_object_R6.R @@ -2231,22 +2231,26 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r year_col <- self$get_columns_from_data(data_name, year) unique_year <- na.omit(unique(year_col)) + # creating our combinations + # if there's a station, we only want to consider the year-station combinations that actually exist + if(is_station) { + expanded_df <- unique(self$get_data_frame(data_name) %>% dplyr::select(year, station)) + } else { + expanded_df <- unique(self$get_data_frame(data_name) %>% dplyr::select(year)) + } + # Set names plant_day_name <- "plant_day" plant_length_name <- "plant_length" rain_total_name <- "rain_total" - expand_list <- list(rain_totals, plant_lengths, plant_days, unique_year) - names_list <- c(rain_total_name, plant_length_name, plant_day_name, year) - - if(is_station) { - station_col <- self$get_columns_from_data(data_name, station) - unique_station <- na.omit(unique(station_col)) - expand_list[[length(expand_list) + 1]] <- unique_station - names_list[length(names_list) + 1] <- station - } + # Create all combinations of X and Y + condition_combinations <- expand.grid(rain_totals, plant_lengths, plant_days) + names_list <- c(rain_total_name, plant_length_name, plant_day_name) + condition_combinations <- setNames(condition_combinations, names_list) - df <- setNames(expand.grid(expand_list), names_list) + # Expand the df with xy_combinations + df <- merge(expanded_df, condition_combinations, by = NULL) daily_data <- self$get_data_frame(data_name) if(season_data_name != data_name) { @@ -2290,13 +2294,11 @@ DataBook$set("public", "crops_definitions", function(data_name, year, station, r # Calculate the sum of rain values and check conditions sum_rain <- sum(rain_values, na.rm = TRUE) - if (anyNA(rain_values)){ #&& sum_rain < data[[rain_total_name]][i]){ - sum_rain <- -1 * sum_rain # as a way to tag the sum_rain value for later, we set as -ve value. - } - - if (length(rain_values) + 1 < data[[plant_length_name]][i]) { - sum_rain <- NA - } + # Set as NA for certain cases: This anyNA is fixed later when we have the total_rainfall value of interest + if (anyNA(rain_values)) sum_rain <- -1 * sum_rain # as a way to tag the sum_rain value for later, we set as -ve value. + #&& sum_rain < data[[rain_total_name]][i]){ + if (length(rain_values) + 1 < data[[plant_length_name]][i]) sum_rain <- NA + if (all(is.na(rain_values))) sum_rain <- NA # Assign the calculated sum to the respective row in the result dataframe data[["rain_total_actual"]][i] <- sum_rain From a0ad4d8c3bc7ba6aff93de3b17adf6a69e5ca106 Mon Sep 17 00:00:00 2001 From: Ntalumeso Date: Thu, 23 Jan 2025 09:51:53 +0300 Subject: [PATCH 35/35] Skipping enable disable undo script in the output window --- instat/Model/DataFrame/clsDataFramePage.vb | 2 +- instat/clsRLink.vb | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/instat/Model/DataFrame/clsDataFramePage.vb b/instat/Model/DataFrame/clsDataFramePage.vb index 062e2216a9..0131071054 100644 --- a/instat/Model/DataFrame/clsDataFramePage.vb +++ b/instat/Model/DataFrame/clsDataFramePage.vb @@ -236,7 +236,7 @@ Public Class clsDataFramePage Dim strDisable As String = If(bDisable, "TRUE", "FALSE") clsEnableDisableUndoRFunction.AddParameter("disable_undo", strDisable) - _clsRLink.RunScript(clsEnableDisableUndoRFunction.ToScript) + _clsRLink.RunScript(clsEnableDisableUndoRFunction.ToScript, bSkipScriptAndOutput:=True) End Sub diff --git a/instat/clsRLink.vb b/instat/clsRLink.vb index e1d6f7b28a..ba19e66b60 100644 --- a/instat/clsRLink.vb +++ b/instat/clsRLink.vb @@ -926,7 +926,8 @@ Public Class RLink Optional bSeparateThread As Boolean = True, Optional bShowWaitDialogOverride As Nullable(Of Boolean) = Nothing, Optional bUpdateGrids As Boolean = True, - Optional bSilent As Boolean = False) + Optional bSilent As Boolean = False, + Optional bSkipScriptAndOutput As Boolean = False) 'if there is no script to run then just ignore and exit sub If String.IsNullOrWhiteSpace(strScript) Then @@ -999,8 +1000,10 @@ Public Class RLink End If End If - ' If strOutput is empty or does not contain valid HTML files, add strOutput itself as an output - clsOutputLogger.AddOutput(strScriptWithComment, strOutput, bAsFile, bDisplayOutputInExternalViewer) + If Not bSkipScriptAndOutput Then + ' If strOutput is empty or does not contain valid HTML files, add strOutput itself as an output + clsOutputLogger.AddOutput(strScriptWithComment, strOutput, bAsFile, bDisplayOutputInExternalViewer) + End If Catch e As Exception