Added removing of fragmented traces; needs more testing

This commit is contained in:
Nora Wickelmaier 2023-10-22 16:52:46 +02:00
parent daadb7a691
commit 8bfa694cc9
1 changed files with 21 additions and 4 deletions

View File

@ -85,6 +85,23 @@ create_eventlogs <- function(data, xmlpath, case_cutoff = 20, rm_nochange_moves
cat("\n\n########## Adding trace variable for move events... ##########", "\n")
dat4 <- add_trace_moves(dat3)
dat4
# Remove fragmented traces ###############################################
tab <- xtabs( ~ trace + event, dat4)
fragments <- NULL
for (i in seq_len(nrow(tab))) {
if (tab[i, "openPopup"] != 0 & tab[i, "flipCard"] == 0) {
fragments <- c(fragments, rownames(tab)[i])
} else if (tab[i, "openTopic"] != 0 & tab[i, "flipCard"] == 0) {
fragments <- c(fragments, rownames(tab)[i])
} else if (tab[i, "openPopup"] != 0 & tab[i, "openTopic"] == 0) {
fragments <- c(fragments, rownames(tab)[i])
}
}
dat5 <- dat4[!dat4$trace %in% fragments, ]
# TODO: Should be tested more thouroughly on complete data set
dat5
}