From 4a1c6778887b13fbc106e696412bc5855b823aa6 Mon Sep 17 00:00:00 2001 From: Don van den Bergh Date: Tue, 18 Jun 2024 13:57:34 +0200 Subject: [PATCH] changes for new variablesList/ data reading --- R/networkanalysis.R | 11 ++++++---- inst/qml/BayesianNetworkAnalysis.qml | 32 ++++++++++++++-------------- inst/qml/NetworkAnalysis.qml | 4 ++-- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/R/networkanalysis.R b/R/networkanalysis.R index 5dd5181..46f85fa 100644 --- a/R/networkanalysis.R +++ b/R/networkanalysis.R @@ -56,10 +56,13 @@ NetworkAnalysis <- function(jaspResults, dataset, options) { groupingVariable <- options[["groupingVariable"]] vars2read <- c(variables, groupingVariable) vars2read <- vars2read[vars2read != ""] - exclude <- c() - if (options[["missingValues"]] == "listwise") - exclude <- vars2read - dataset <- .readDataSetToEnd(columns.as.numeric = vars2read, exclude.na.listwise = exclude) + + exclude <- if (options[["missingValues"]] == "listwise") + c(vars2read, groupingVariable) + else if (groupingVariable != "") + exclude <- groupingVariable + + dataset <- .readDataSetToEnd(columns.as.numeric = variables, columns.as.factor = if (groupingVariable != "") groupingVariable else NULL, exclude.na.listwise = exclude) # dataset <- .readDataSetToEnd(columns = vars2read, exclude.na.listwise = exclude) # jaspTools need this, JASP the line above if (options[["groupingVariable"]] == "") { # one network diff --git a/inst/qml/BayesianNetworkAnalysis.qml b/inst/qml/BayesianNetworkAnalysis.qml index 9f2cb9e..b3d8efb 100644 --- a/inst/qml/BayesianNetworkAnalysis.qml +++ b/inst/qml/BayesianNetworkAnalysis.qml @@ -27,10 +27,10 @@ Form VariablesForm { AvailableVariablesList { name: "allVariablesList" } - AssignedVariablesList { name: "variables"; title: qsTr("Dependent Variables"); suggestedColumns: ["scale"]; id: networkVariables} - AssignedVariablesList { name: "groupingVariable"; title: qsTr("Split"); singleVariable: true; suggestedColumns: ["ordinal", "nominal"] } + AssignedVariablesList { name: "variables"; title: qsTr("Dependent Variables"); allowedColumns: ["scale"]; minNumericLevels: 2; id: networkVariables} + AssignedVariablesList { name: "groupingVariable"; title: qsTr("Split"); singleVariable: true; allowedColumns: ["nominal"]; minLevels: 2 } } - + DropDown { id: estimator @@ -47,8 +47,8 @@ Form { title: qsTr("Plots") CheckBox { name: "networkPlot"; label: qsTr("Network plot") } - CheckBox { - name: "evidencePlot"; + CheckBox { + name: "evidencePlot"; label: qsTr("Edge evidence plot") IntegerField { name: "edgeInclusionCriteria"; @@ -61,12 +61,12 @@ Form CheckBox { name: "edgeExclusion"; label: qsTr("Evidence for exclusion"); checked: true } CheckBox { name: "edgeAbsence"; label: qsTr("Absence of evidence"); checked: true } } - CheckBox { - name: "centralityPlot"; label: qsTr("Centrality plot") - CheckBox { + CheckBox { + name: "centralityPlot"; label: qsTr("Centrality plot") + CheckBox { name: "credibilityInterval"; label: qsTr("Credibility interval 95%"); - checked: false + checked: false } } } @@ -75,7 +75,7 @@ Form { title: qsTr("Tables") CheckBox { name: "weightsMatrixTable"; label: qsTr("Weights matrix") } - CheckBox { + CheckBox { name: "edgeEvidenceTable"; label: qsTr("Edge evidence probability table") RadioButtonGroup { name: "evidenceType"; @@ -87,14 +87,14 @@ Form } CheckBox { name: "centralityTable"; label: qsTr("Centrality table") } } - - Section + + Section { title: qsTr("Sampling Options") Layout.columnSpan: 2 IntegerField { name: "burnin"; label: qsTr("Burn in: "); value: "5000" ; min: 0; max: iter.value / 2; fieldWidth: 100; id: burnin } IntegerField { name: "iter"; label: qsTr("Iterations: "); value: "10000" ; min: burnin.value * 2; fieldWidth: 100; id: iter } - + SetSeed{} } @@ -103,7 +103,7 @@ Form title: qsTr("Prior") FormulaField { name: "gprior"; label: qsTr("Prior edge inclusion (g prior): "); value: "0.5" ; min: 0.001; max: 1; Layout.columnSpan: 2 } - + DropDown { id: initialConfiguration @@ -245,7 +245,7 @@ Form RadioButton { value: "inNodes"; label: qsTr("In plot"); checked: true } RadioButton { value: "inLegend"; label: qsTr("In legend") } } - + RadioButtonGroup { name: "legend" @@ -291,7 +291,7 @@ Form CheckBox { name: "expectedInfluence"; label: qsTr("Expected influence"); checked: true } } } - + Section { title: qsTr("Network structure selection") diff --git a/inst/qml/NetworkAnalysis.qml b/inst/qml/NetworkAnalysis.qml index d1bc7b4..6a205f4 100644 --- a/inst/qml/NetworkAnalysis.qml +++ b/inst/qml/NetworkAnalysis.qml @@ -27,8 +27,8 @@ Form VariablesForm { AvailableVariablesList { name: "allVariablesList" } - AssignedVariablesList { name: "variables"; title: qsTr("Dependent Variables"); suggestedColumns: ["ordinal", "scale"]; id: networkVariables} - AssignedVariablesList { name: "groupingVariable"; title: qsTr("Split"); singleVariable: true; suggestedColumns: ["ordinal", "nominal"] } + AssignedVariablesList { name: "variables"; title: qsTr("Dependent Variables"); allowedColumns: ["scale"]; minNumericLevels: 2; id: networkVariables} + AssignedVariablesList { name: "groupingVariable"; title: qsTr("Split"); singleVariable: true; allowedColumns: ["nominal"]; minLevels: 2 } } DropDown