Skip to content

Commit b796aae

Browse files
committed
finish manual riskset option
1 parent 4e8c27b commit b796aae

File tree

7 files changed

+275
-158
lines changed

7 files changed

+275
-158
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: jaspRem
22
Type: Package
33
Title: REM
4-
Version: 0.19
4+
Version: 0.19.0
55
Date: 2024-06-05
66
Author: JASP Team
77
Website: jasp-stats.org

R/relationalEventModeling.R

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -166,42 +166,29 @@ relationalEventModeling <- function(jaspResults, dataset, options) {
166166

167167
.remUploadDyadExcludeData <- function(jaspResults, options) {
168168

169-
dyadExcludePaths <- sapply(options[["dyadExcludeList"]], function(x) x[["dyadExclude"]])
169+
if (!is.null(jaspResults[["dyadExcludeState"]]$object) || options[["riskset"]] != "manual" ||
170+
is.null(options[["dyadExclude"]])) return()
170171

171-
if (all(dyadExcludePaths == "")) return()
172+
if (options[["dyadExclude"]] == "") return()
172173

173-
if (!is.null(jaspResults[["dyadExcludeState"]]$object) || options[["riskset"]] != "custom") return()
174+
bsName <- basename(options[["dyadExclude"]])
175+
attrName <- gsub("\\..*","", bsName)
176+
ending <- sub(".*(\\..*)", "\\1", bsName)
174177

175-
dyadOut <- list()
176-
for (i in 1:length(dyadExcludePaths)) {
177-
178-
if (dyadExcludePaths[i] != "") {
179-
180-
bsName <- basename(options[["dyadExcludeList"]][[i]][["dyadExclude"]])
181-
attrName <- gsub("\\..*","", bsName)
182-
ending <- sub(".*(\\..*)", "\\1", bsName)
183-
184-
if (ending == ".csv") {
185-
dyadDt <- read.csv(options[["dyadExcludeList"]][[i]][["dyadExclude"]], row.names = NULL, check.names = FALSE)
186-
} else if (ending == ".txt") {
187-
dyadDt <- read.delim(options[["dyadExcludeList"]][[i]][["dyadExclude"]], row.names = NULL, check.names = FALSE)
188-
}
189-
190-
dyadDt$type <- NA
191-
# # this is only necessary for the wide format...
192-
# if (ncol(dyadDt) == nrow(dyadDt)) {
193-
# rownames(dyadDt) <- colnames(dyadDt)
194-
# }
195-
196-
dyadOut[[attrName]] <- dyadDt
178+
if (ending == ".csv") {
179+
dyadDt <- read.csv(options[["dyadExclude"]], row.names = NULL, check.names = FALSE)
180+
} else if (ending == ".txt") {
181+
dyadDt <- read.delim(options[["dyadExclude"]], row.names = NULL, check.names = FALSE)
182+
}
197183

198-
} else {
199-
dyadOut[[i]] <- NULL
200-
}
184+
cnames <- colnames(dyadDt)
185+
if (!all(c("actor1", "actor2") %in% cnames)) {
186+
.quitAnalysis(gettext("The columns in the dyad exclude data file should be named 'actor1' and 'actor2'"))
201187
}
202188

203-
dyadExcludeState <- createJaspState(dyadOut)
204-
dyadExcludeState$dependOn("dyadExcludeList")
189+
dyadDt <- dyadDt[, c("actor1", "actor2")]
190+
dyadExcludeState <- createJaspState(dyadDt)
191+
dyadExcludeState$dependOn(c("riskset", "dyadExclude"))
205192
jaspResults[["dyadExcludeState"]] <- dyadExcludeState
206193

207194
return()
@@ -573,11 +560,11 @@ relationalEventModeling <- function(jaspResults, dataset, options) {
573560
}
574561

575562
if (!is.null(jaspResults[["dyadExcludeState"]][["object"]])) {
576-
dtExcludeList <- jaspResults[["dyadExcludeState"]][["object"]]
577-
omitDyad <- list()
578-
for (i in 1:length(dtExcludeList)) {
579-
omitDyad <- append(omitDyad, list(time = c(NA,NA), dyad = dtExcludeList[[i]]))
580-
}
563+
dtExclude <- jaspResults[["dyadExcludeState"]][["object"]]
564+
dtExclude <- lapply(dtExclude, as.character)
565+
dtExclude$type <- NA
566+
567+
omitDyad <- list(list(time = c(NA,NA), dyad = dtExclude))
581568
} else {
582569
omitDyad <- NULL
583570
}

inst/qml/RelationalEventModeling.qml

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -182,27 +182,19 @@ Form
182182
{
183183
value: "manual"
184184
label: qsTr("Manual")
185-
ComponentsList
185+
186+
Label { text: qsTr("Upload dyads to exclude:"); visible: riskset.value == "manual" }
187+
188+
FileSelector
186189
{
187-
visible: riskset.value == "manual"
188-
name: "dyadExcludeList"
189-
title: qsTr("Upload dyads to exclude from the riskset")
190-
implicitHeight: 90 * preferencesModel.uiScale // about 3 rows
191-
minimumItems: 1
192-
rowComponent:
193-
RowLayout
194-
{
195-
FileSelector
196-
{
197-
id: dyadExclude
198-
name: "dyadExclude"
199-
label: ""
200-
placeholderText: qsTr("e.g., home/Data/dyadExclude.csv")
201-
filter: "*.csv *.txt"
202-
save: false
203-
fieldWidth: 180 * preferencesModel.uiScale
204-
}
205-
}
190+
id: dyadExclude
191+
visible: riskset.value == "manual"
192+
name: "dyadExclude"
193+
label: ""
194+
placeholderText: qsTr("e.g., home/Data/dyadExclude.csv")
195+
filter: "*.csv *.txt"
196+
save: false
197+
fieldWidth: 180 * preferencesModel.uiScale
206198
}
207199
}
208200

renv.lock

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,12 +1096,10 @@
10961096
"Package": "jaspBase",
10971097
"Version": "0.19.0",
10981098
"Source": "GitHub",
1099-
"Remotes": "jasp-stats/jaspGraphs",
11001099
"RemoteType": "github",
11011100
"RemoteHost": "api.github.com",
1102-
"RemoteRepo": "jaspBase",
11031101
"RemoteUsername": "jasp-stats",
1104-
"RemoteRef": "HEAD",
1102+
"RemoteRepo": "jaspBase",
11051103
"RemoteSha": "7de02c442478e028fe2036e3b906059bf504c13e",
11061104
"Requirements": [
11071105
"R6",
@@ -1141,7 +1139,6 @@
11411139
"RemoteHost": "api.github.com",
11421140
"RemoteRepo": "jaspGraphs",
11431141
"RemoteUsername": "jasp-stats",
1144-
"RemoteRef": "HEAD",
11451142
"RemoteSha": "09e2fecf1b921a00a203a442207591ecd3db2821",
11461143
"Requirements": [
11471144
"R6",
@@ -1165,7 +1162,6 @@
11651162
"RemoteHost": "api.github.com",
11661163
"RemoteRepo": "jaspTools",
11671164
"RemoteUsername": "jasp-stats",
1168-
"RemoteRef": "HEAD",
11691165
"RemoteSha": "6caf5dd91f1469f4357cd6dc78b3600711e871ea",
11701166
"Requirements": [
11711167
"archive",
@@ -1852,13 +1848,13 @@
18521848
},
18531849
"renv": {
18541850
"Package": "renv",
1855-
"Version": "1.0.3",
1851+
"Version": "1.0.9",
18561852
"Source": "Repository",
1857-
"Repository": "CRAN",
1853+
"Repository": "RSPM",
18581854
"Requirements": [
18591855
"utils"
18601856
],
1861-
"Hash": "41b847654f567341725473431dd0d5ab"
1857+
"Hash": "ef233f0e9064fc88c898b340c9add5c2"
18621858
},
18631859
"reshape2": {
18641860
"Package": "reshape2",
@@ -2075,7 +2071,6 @@
20752071
"RemoteHost": "api.github.com",
20762072
"RemoteRepo": "shrinkem",
20772073
"RemoteUsername": "jomulder",
2078-
"RemoteRef": "HEAD",
20792074
"RemoteSha": "b5699e9b14120127dbbb8f6b2c59b188872e6263",
20802075
"Requirements": [
20812076
"CholWishart",

0 commit comments

Comments
 (0)