mtt_haum/code/05_check-traces.R

120 lines
4.0 KiB
R
Raw Normal View History

# 05_check-traces.R
#
# content: (1) Look at broken trace
# (2) Function to find broken traces
2024-03-09 17:22:46 +01:00
# (3) DFG for complete data
# (4) Export data frame for analyses
#
# input: results/haum/event_logfiles_2024-02-21_16-07-33.csv
# results/haum/raw_logfiles_2024-02-21_16-07-33.csv
# output: results/haum/eventlogs_pre-corona_cleaned.RData
# results/haum/eventlogs_pre-corona_cleaned.csv
#
# last mod: 2024-03-06
# setwd("C:/Users/nwickelmaier/Nextcloud/Documents/MDS/2023ss/60100_master_thesis/analysis/code")
#--------------- (1) Look at broken trace ---------------
2024-01-16 09:59:23 +01:00
datraw <- read.table("results/haum/raw_logfiles_2024-02-21_16-07-33.csv",
header = TRUE, sep = ";")
2024-01-16 09:59:23 +01:00
datlogs <- read.table("results/haum/event_logfiles_2024-02-21_16-07-33.csv",
colClasses = c("character", "character", "POSIXct",
"POSIXct", "character", "integer",
"numeric", "character", "character",
rep("numeric", 3), "character",
"character", rep("numeric", 11),
"character", "character"),
sep = ";", header = TRUE)
artwork <- "176"
fileId <- c('2017_06_16-13_49_00.log', '2017_06_16-13_59_00.log')
path <- 106098
2024-01-16 09:59:23 +01:00
datraw[datraw$item == artwork & datraw$fileId %in% fileId, ]
2024-01-16 09:59:23 +01:00
datlogs[datlogs$path == path, ]
#--------------- (2) Function to find broken traces ---------------
tmp <- datlogs[datlogs$event != "move", ]
check_traces <- function(data) {
datagg <- aggregate(event ~ path, data,
function(x) ifelse("openPopup" %in% x, T, F))
paths <- datagg$path[datagg$event]
datcheck <- data[data$path %in% paths, c("path", "event")]
datcheck <- datcheck[!duplicated(datcheck), ]
datcheck <- datcheck[order(datcheck$path), ]
retval <- NULL
for (path in unique(datcheck$path)) {
check <- !all(as.character(datcheck$event[datcheck$path == path]) ==
c("flipCard", "openTopic", "openPopup"))
retval <- rbind(retval, data.frame(path, check))
}
retval
}
check <- check_traces(tmp)
check[check$check, ]
2024-01-30 09:46:40 +01:00
2024-03-09 17:22:46 +01:00
#--------------- (3) DFG for complete data ---------------
tmp <- datlogs[datlogs$path != 106098, ]
tmp$start <- tmp$date.start
tmp$complete <- tmp$date.stop
alog <- bupaR::activitylog(tmp,
case_id = "path",
activity_id = "event",
resource_id = "item",
timestamps = c("start", "complete"))
dfg <- processmapR::process_map(alog,
type_nodes = processmapR::frequency("relative", color_scale = "Greys"),
sec_nodes = processmapR::frequency("absolute"),
type_edges = processmapR::frequency("relative", color_edges = "#FF6900"),
sec_edges = processmapR::frequency("absolute"),
rankdir = "LR",
render = FALSE)
processmapR::export_map(dfg,
file_name = paste0("results/processmaps/dfg_complete_WFnet_R.pdf"),
2024-03-09 17:22:46 +01:00
file_type = "pdf")
rm(tmp)
#--------------- (4) Export data frame for analyses ---------------
datlogs$event <- factor(datlogs$event, levels = c("move", "flipCard",
"openTopic",
"openPopup"))
datlogs$topic <- factor(datlogs$topic)
datlogs$weekdays <- factor(weekdays(datlogs$date.start),
levels = c("Montag", "Dienstag", "Mittwoch",
"Donnerstag", "Freitag", "Samstag",
"Sonntag"),
labels = c("Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday",
"Sunday"))
# Select data pre Corona
dat <- datlogs[as.Date(datlogs$date.start) < "2020-03-13", ]
# Remove corrupt trace
dat <- dat[dat$path != 106098, ]
save(dat, file = "results/haum/eventlogs_pre-corona_cleaned.RData")
write.table(dat,
file = "results/haum/eventlogs_pre-corona_cleaned.csv",
sep = ";",
quote = FALSE,
row.names = FALSE)