Skip to content

Commit 71dfe9b

Browse files
committed
get preload data to work
1 parent c69909b commit 71dfe9b

File tree

4 files changed

+16
-27
lines changed

4 files changed

+16
-27
lines changed

R/relationalEventModeling.R

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ relationalEventModeling <- function(jaspResults, dataset, options) {
3737
# create a container for the main results that passes down dependencies to everything saved withiin
3838
.remMainContainer(jaspResults, options)
3939

40-
4140
ready <- (options[["timeVariable"]] != "") && (options[["actorVariableSender"]] != "") && (options[["actorVariableReceiver"]] != "")
4241

4342
if (ready && !options[["syncAnalysisBox"]]) {
@@ -49,7 +48,7 @@ relationalEventModeling <- function(jaspResults, dataset, options) {
4948

5049
if (ready && options[["syncAnalysisBox"]]) {
5150

52-
dataset <- .remReadData(jaspResults, dataset, options)
51+
dataset <- .remHandleData(jaspResults, dataset, options)
5352

5453
.remErrorHandling(jaspResults, dataset, options)
5554

@@ -438,10 +437,7 @@ relationalEventModeling <- function(jaspResults, dataset, options) {
438437

439438

440439
# ----------- Main analysis -------------
441-
.remReadData <- function(jaspResults, dataset, options) {
442-
443-
if (!is.null(dataset))
444-
return(dataset)
440+
.remHandleData <- function(jaspResults, dataset, options) {
445441

446442
variables <- c(options$timeVariable, options$actorVariableSender, options$actorVariableReceiver)
447443
if (options$weightVariable != "") {
@@ -461,10 +457,11 @@ relationalEventModeling <- function(jaspResults, dataset, options) {
461457
tmp1 <- lapply(exoEffects, function(x) names(x) == "event")
462458
tmp2 <- unlist(lapply(tmp1, any))
463459
eventNames <- unique(names(tmp2[tmp2]))
464-
variables <- c(variables, jaspBase::encodeColNames(eventNames))
460+
eventIndices <- which(eventNames == decodeColNames(colnames(dataset)))
461+
variables <- c(variables, colnames(dataset)[eventIndices])
465462
}
466463

467-
dataset <- .readDataSetToEnd(columns = variables)
464+
dataset <- dataset[, variables]
468465

469466
colnames(dataset)[1:3] <- jaspBase::encodeColNames(c("time", "actor1", "actor2"))
470467

@@ -677,7 +674,6 @@ relationalEventModeling <- function(jaspResults, dataset, options) {
677674
return()
678675
}
679676

680-
681677
# in the first round both states are created
682678
statsObject <- try(remstats::remstats(reh = rehObject, tie_effects = ties, sender_effects = senders,
683679
receiver_effects = receivers,
@@ -1678,15 +1674,16 @@ relationalEventModeling <- function(jaspResults, dataset, options) {
16781674
exoEffects[ii] <- sub("(\\'.*?)\\'", paste0("\\1', ", dtName), exoEffects[ii])
16791675
}
16801676

1681-
} else { # everything that is not event and tie is also in the attr actors object
1682-
ma <- regexpr("'(.*?)'", exoEffects[ii])
1683-
effVarName <- gsub("'", "", regmatches(exoEffects[ii], ma), fixed = TRUE)
1684-
ind <- grep(effVarName, actorVarNames)
1685-
if (length(ind) > 0) {
1686-
dtName <- actorDataNames[[ind]]
1687-
exoEffects[ii] <- sub("(\\'.*?)\\'", paste0("\\1', ", dtName), exoEffects[ii])
1677+
} else { # everything that is not event and tie is also in the attr actors object (if that exists)
1678+
if (!is.null(actorDataList)) {
1679+
ma <- regexpr("'(.*?)'", exoEffects[ii])
1680+
effVarName <- gsub("'", "", regmatches(exoEffects[ii], ma), fixed = TRUE)
1681+
ind <- grep(effVarName, actorVarNames)
1682+
if (length(ind) > 0) {
1683+
dtName <- actorDataNames[[ind]]
1684+
exoEffects[ii] <- sub("(\\'.*?)\\'", paste0("\\1', ", dtName), exoEffects[ii])
1685+
}
16881686
}
1689-
16901687
}
16911688

16921689
exoDims <- append(exoDims, dimstmp)

inst/Description.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Description
1313
license : "GPL (>= 2)"
1414
icon : "logoFreq.png"
1515
hasWrappers : false
16-
preloadData: false
16+
preloadData: true
1717

1818
Analysis
1919
{

inst/qml/RelationalEventModeling.qml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,7 @@ Form
348348
CheckBox {
349349
name: "endogenousEffectsUnique"
350350
Layout.preferredWidth: 60
351-
visible: effects.varsUnique.includes(rowValue)
352-
enabled: inclEndoEff.checked
351+
enabled: inclEndoEff.checked & effects.varsUnique.includes(rowValue)
353352
}
354353
}
355354
}
@@ -402,13 +401,6 @@ Form
402401
title: orientation.value == "tie" ? qsTr("Exogenous effects") : qsTr("Exogenous effects receiver model")
403402
implicitHeight: 150 * preferencesModel.uiScale
404403

405-
// workaround since the headerLabels for the componentlist keep screwing up
406-
// Text { text: orientation.value == "tie" ?
407-
// (eventDirection.value == "directed" ?
408-
// qsTr(" Average Difference Event Maximum Minimum Receive Same Send Tie") :
409-
// qsTr(" Average Difference Event Maximum Minimum Same Tie")) :
410-
// qsTr(" Average Difference Receive Same Tie")
411-
// }
412404
ComponentsList
413405
{
414406
id: exogenousEffectsTable

tests/testthat/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)