Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

updated my master #503

Merged
merged 20 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions instat/clsRLink.vb
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ Public Class RLink
MsgBox(ex.Message & Environment.NewLine & "Could not establish connection to R." & Environment.NewLine &
"R-Instat requires version " & strRVersionRequired & " of R." & Environment.NewLine &
"Note that R-Instat does not work with R below 4.4.1. We recommend using R " & strRBundledVersion &
". Try reruning the installation to install R " & strRBundledVersion & " or download R " &
strRBundledVersion & " from https://cran.r-project.org/bin/windows/base/old/" & strRBundledVersion & "/ and restart R-Instat.",
". Try rerunning the installation to install R " & strRBundledVersion & " or download R " &
strRBundledVersion & " from https://cran.r-project.org/bin/windows/base/old/" & strRBundledVersion & "/ and restart R-Instat.",
MsgBoxStyle.Critical, "Cannot initialise R connection.")
End Try

Expand All @@ -228,7 +228,7 @@ Public Class RLink
MsgBox("Could not determine version of R installed on your machine. R-Instat requires version: " & strRVersionRequired & vbNewLine &
"Try uninstalling any versions of R and rerun the installation to install R " & strRVersionRequired & " or download R " &
strRVersionRequired & "From https://cran.r-project.org/bin/windows/base/old/" & strRVersionRequired &
"And restart R-Instat.",
" and restart R-Instat.",
MsgBoxStyle.Critical, "R Version error.")
ElseIf strMajor <> strRVersionMajorRequired OrElse strMinor.Substring(0, 1) < strRVersionMinorRequired Then
MsgBox("Your current version of R is outdated. You are currently running R version: " & strMajor & "." & strMinor & Environment.NewLine &
Expand Down
33 changes: 18 additions & 15 deletions instat/dlgColumnStats.vb
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ Public Class dlgColumnStats
ucrChkOriginalLevel.SetValuesCheckedAndUnchecked("TRUE", "FALSE")
ucrChkOriginalLevel.SetRDefault("FALSE")

ucrChkPrintOutput.SetParameter(New RParameter("return_output", 4))
ucrChkPrintOutput.SetText("Print Results to Output Window")
ucrChkPrintOutput.SetValuesCheckedAndUnchecked("TRUE", "FALSE")
ucrChkPrintOutput.SetRDefault("FALSE")

ucrChkDropUnusedLevels.SetParameter(New RParameter("drop", 5))
ucrChkDropUnusedLevels.SetText("Drop Unused Levels")
Expand Down Expand Up @@ -117,6 +114,7 @@ Public Class dlgColumnStats

clsDefaultFunction.SetRCommand(frmMain.clsRLink.strInstatDataObject & "$calculate_summary")
clsDefaultFunction.AddParameter("summaries", clsRFunctionParameter:=clsSummariesList)
clsDefaultFunction.AddParameter("store_results", "TRUE", iPosition:=3)
'Prevents an error if user chooses non count summaries with no columns to summarise
clsDefaultFunction.AddParameter("silent", "TRUE")
ucrBase.clsRsyntax.SetBaseRFunction(clsDefaultFunction)
Expand Down Expand Up @@ -157,11 +155,7 @@ Public Class dlgColumnStats
End Sub

Public Sub TestOKEnabled()
If ((ucrChkStoreResults.Checked OrElse ucrChkPrintOutput.Checked) AndAlso Not clsSummariesList.clsParameters.Count = 0) AndAlso sdgSummaries.bOkEnabled Then
ucrBase.OKEnabled(True)
Else
ucrBase.OKEnabled(False)
End If
ucrBase.OKEnabled(Not clsSummariesList.clsParameters.Count = 0 AndAlso sdgSummaries.bOkEnabled AndAlso Not ucrReceiverSelectedVariables.IsEmpty)
End Sub

Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset
Expand Down Expand Up @@ -226,14 +220,23 @@ Public Class dlgColumnStats
sdgMissingOptions.ShowDialog()
End Sub

'Private Sub ucrReceiverSelectedVariables_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverSelectedVariables.ControlValueChanged
' Dim bSameType As Boolean = Not ucrReceiverSelectedVariables.IsEmpty _
' AndAlso ucrReceiverSelectedVariables.GetCurrentItemTypes().All(Function(x) x = "factor")
' ucrChkDropUnusedLevels.Enabled = bSameType
' ucrChkDropUnusedLevels.Checked = Not bSameType
'End Sub
Private Sub ucrReceiverByFactor_ControlValueChanged(ucrChangedControl As ucrCore) Handles ucrReceiverByFactor.ControlValueChanged, ucrChkStoreResults.ControlValueChanged, ucrChkPrintOutput.ControlValueChanged
If ucrReceiverByFactor.IsEmpty Then
clsDefaultFunction.AddParameter("store_results", "FALSE", iPosition:=3)
clsDefaultFunction.AddParameter("return_output", "TRUE", iPosition:=4)
ucrBase.clsRsyntax.iCallType = 2
Else
clsDefaultFunction.RemoveParameterByName("return_output")
If ucrChkStoreResults.Checked Then
clsDefaultFunction.AddParameter("store_results", "TRUE", iPosition:=3)
End If
If ucrChkPrintOutput.Checked Then
clsDefaultFunction.AddParameter("return_output", "TRUE", iPosition:=4)
End If
End If
End Sub

Private Sub CoreControls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrChkPrintOutput.ControlContentsChanged, ucrChkStoreResults.ControlContentsChanged
Private Sub CoreControls_ControlContentsChanged(ucrChangedControl As ucrCore) Handles ucrReceiverSelectedVariables.ControlContentsChanged
TestOKEnabled()
End Sub
End Class
1 change: 1 addition & 0 deletions instat/dlgDistances.vb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Public Class dlgDistances
autoTranslate(Me)
End Sub
Private Sub InitialiseDialog()
ucrBase.iHelpTopicID = 145

ucrSelectorDistance.SetParameter(New RParameter("df", 0))
ucrSelectorDistance.SetParameterIsrfunction()
Expand Down
Binary file modified instat/static/Help/R-Instat.chm
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,20 @@ DataBook$set("public", "calculate_summary", function(data_name, columns_to_summa
curr_filter_name <- curr_filter[["name"]]
curr_filter_calc <- self$get_filter_as_instat_calculation(data_name, curr_filter_name)
manipulations <- c(curr_filter_calc, manipulations)
}
}
if(!missing(additional_filter)) {
manipulations <- c(additional_filter, manipulations)
}
combined_calc_sum <- instat_calculation$new(type="combination", sub_calculations = sub_calculations, manipulations = manipulations)

# setting up param_list. Here we read in .drop and .preserve
param_list <- list()
for (i in 1:length(combined_calc_sum$manipulations)){
if (combined_calc_sum$manipulations[[i]]$type %in% c("by", "filter")){
param_list <- c(param_list, combined_calc_sum$manipulations[[i]]$param_list)
}
if (length(combined_calc_sum$manipulations) > 0){
for (i in 1:length(combined_calc_sum$manipulations)){
if (combined_calc_sum$manipulations[[i]]$type %in% c("by", "filter")){
param_list <- c(param_list, combined_calc_sum$manipulations[[i]]$param_list)
}
}
}
out <- self$apply_instat_calculation(combined_calc_sum, param_list = param_list)
# relocate so that the factors are first still for consistency
Expand Down Expand Up @@ -1063,11 +1065,12 @@ summary_Sn <- function(x, constant = 1.1926, finite.corr = missing(constant), na
}

# cor function
summary_cor <- function(x, y, na.rm = FALSE, na_type = "", weights = NULL, method = c("pearson", "kendall", "spearman"), use = c( "everything", "all.obs", "complete.obs", "na.or.complete", "pairwise.complete.obs"), ...) {
summary_cor <- function(x, y, na.rm = FALSE, na_type = "", weights = NULL, method = c("pearson", "kendall", "spearman"), cor_use = c("everything", "all.obs", "complete.obs", "na.or.complete", "pairwise.complete.obs"), ...) {
cor_use <- match.arg(cor_use)
if (na.rm && na_type != "" && !na_check(x, na_type = na_type, ...)) return(NA)
else {
if (missing(weights) || is.null(weights)) {
return(cor(x = x, y = y, use = use, method = method))
return(cor(x = x, y = y, use = cor_use, method = method))
}
else {
weights::wtd.cor(x = x, y = y, weight = weights)[1]
Expand Down
9 changes: 7 additions & 2 deletions instat/static/InstatObject/R/data_object_R6.R
Original file line number Diff line number Diff line change
Expand Up @@ -1263,8 +1263,13 @@ DataSheet$set("public", "paste_from_clipboard", function(col_names, start_row_po
#set the row positions and the values
rows_to_replace <- c(start_row_pos : (start_row_pos + nrow(clip_tbl) - 1 ))
new_values <- clip_tbl[,index]
#replace the old values with new values
self$replace_value_in_data(col_names = col_names[index], rows = rows_to_replace, new_value = new_values)

# Replace the old values with new values
for (i in seq_along(new_values)) {
# Replace each value one by one
self$replace_value_in_data(col_names = col_names[index], rows = rows_to_replace[i], new_value = new_values[i])
}

#rename header if first row of clip data is header.
if(first_clip_row_is_header){
self$rename_column_in_data(curr_col_name = col_names[index], new_col_name = colnames(clip_tbl)[index])
Expand Down
2 changes: 1 addition & 1 deletion instat/ucrDataView.vb
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ Public Class ucrDataView
End Sub

Private Sub mnuHelp_Click(sender As Object, e As EventArgs) Handles mnuHelp.Click, mnuHelp1.Click, mnuHelp2.Click, mnuHelp3.Click
Help.ShowHelp(frmMain, frmMain.strStaticPath & "/" & frmMain.strHelpFilePath, HelpNavigator.TopicId, "134")
Help.ShowHelp(frmMain, frmMain.strStaticPath & "/" & frmMain.strHelpFilePath, HelpNavigator.TopicId, "697")
End Sub

Public Sub GoToSpecificRowPage(iPage As Integer)
Expand Down
Loading