Added argument glossar so that glossar entries can be ignored completely

This commit is contained in:
Nora Wickelmaier 2023-10-25 16:19:15 +02:00
parent 64241bf5f9
commit ee35481130

View File

@ -11,17 +11,20 @@
#' @param rm_nochange_moves Logical. Should move events that record no
#' change, meaning distance and rotationDegree are 0 and scaleSize is 1, be
#' removed. Default is TRUE.
#' @param glossar Logical indicating of glossar folder is present and if it
#' should be taken into account when preprocessing raw log files. Default
#' is FALSE.
#' @return Data frame.
#' @export
#' @examples
#' # tbd
create_eventlogs <- function(data, xmlpath, case_cutoff = 20, rm_nochange_moves = TRUE) {
create_eventlogs <- function(data, xmlpath, case_cutoff = 20, rm_nochange_moves = TRUE,
glossar = FALSE) {
if (!lubridate::is.POSIXt(data$date)){
cat("########## Converting variable `date` to POSIXct ##########", "\n")
data$date <- as.POSIXct(data$date)
}
data$glossar <- ifelse(data$artwork == "glossar", 1, 0)
# Remove irrelevant events
dat <- subset(data, !(data$event %in% c("Start Application",
@ -30,7 +33,9 @@ create_eventlogs <- function(data, xmlpath, case_cutoff = 20, rm_nochange_moves
artworks <- unique(stats::na.omit(dat$artwork))
# Create glossar dictionary ##############################################
if ("glossar" %in% artworks) {
if (glossar) {
dat$glossar <- ifelse(dat$artwork == "glossar", 1, 0)
cat("\n########## Creating glossar dictionary ##########", "\n")
artworks <- artworks[artworks != "glossar"]
glossar_files <- unique(subset(dat, dat$artwork == "glossar")$popup)
@ -117,6 +122,8 @@ create_eventlogs <- function(data, xmlpath, case_cutoff = 20, rm_nochange_moves
}
dat5 <- dat4[!dat4$trace %in% fragments, ]
if (!glossar) dat5$glossar <- NULL
dat5
}