2023-09-26 18:34:59 +02:00
|
|
|
# setwd("C:/Users/nwickelmaier/Nextcloud/Documents/MDS/2023ss/60100_master_thesis/code/")
|
2023-09-21 16:45:06 +02:00
|
|
|
|
2023-09-26 18:34:59 +02:00
|
|
|
library(lattice)
|
2024-01-09 17:45:16 +01:00
|
|
|
#library(mtt)
|
|
|
|
devtools::load_all("../../../../software/mtt")
|
2023-09-26 18:34:59 +02:00
|
|
|
|
2023-09-26 18:39:02 +02:00
|
|
|
# Achims colors (used by lattice)
|
2023-09-29 15:04:11 +02:00
|
|
|
#cc <- palette.colors(palette = "Okabe-Ito")
|
|
|
|
#plot(1:10, col = cc, pch = 16, cex = 2)
|
2023-09-26 18:39:02 +02:00
|
|
|
|
2023-09-26 18:34:59 +02:00
|
|
|
# Read data
|
2024-01-09 17:45:16 +01:00
|
|
|
|
|
|
|
datlogs <- read.table("results/haum/event_logfiles_2024-01-02_19-44-50.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)
|
|
|
|
|
|
|
|
datlogs$event <- factor(datlogs$event, levels = c("move", "flipCard",
|
|
|
|
"openTopic",
|
|
|
|
"openPopup"))
|
|
|
|
|
|
|
|
### Number of log files
|
|
|
|
length(unique(datlogs$fileId.start))
|
|
|
|
length(unique(datlogs$fileId.stop))
|
|
|
|
|
|
|
|
length(unique(c(datlogs$fileId.start, datlogs$fileId.stop)))
|
|
|
|
# 22803
|
|
|
|
|
|
|
|
### Number of activities
|
|
|
|
nrow(datlogs)
|
|
|
|
table(datlogs$event)
|
|
|
|
proportions(table(datlogs$event))
|
|
|
|
proportions(table(datlogs$event[datlogs$event != "move"]))
|
|
|
|
|
|
|
|
### Time range
|
|
|
|
range(as.Date(datlogs$date.start))
|
|
|
|
|
|
|
|
### Topics per item
|
|
|
|
print(xtabs( ~ item + topic, datlogs), zero = "-")
|
|
|
|
lattice::dotplot(xtabs( ~ item + topic, datlogs), auto.key = TRUE)
|
|
|
|
|
|
|
|
### Which item gets touched most often?
|
|
|
|
|
|
|
|
counts_item <- table(datlogs$item)
|
|
|
|
barchart(counts_item)
|
|
|
|
|
|
|
|
items <- unique(datlogs$item)
|
|
|
|
#items <- items[!items %in% c("504", "505")]
|
|
|
|
datart <- extract_artworks(items,
|
|
|
|
paste0(items, ".xml"),
|
2023-09-26 18:34:59 +02:00
|
|
|
"../data/haum/ContentEyevisit/eyevisit_cards_light/")
|
|
|
|
datart <- datart[order(datart$artwork), ]
|
2024-01-09 17:45:16 +01:00
|
|
|
names(counts_item) <- datart$title
|
2023-09-26 18:34:59 +02:00
|
|
|
|
2024-01-09 17:45:16 +01:00
|
|
|
pdf("../figures/counts_item.pdf", width = 20, height = 10, pointsize = 10)
|
2023-09-26 18:34:59 +02:00
|
|
|
par(mai = c(5, .6, .1, .1))
|
2024-01-09 17:45:16 +01:00
|
|
|
tmp <- barplot(counts_item, las = 2, ylim = c(0, 60000),
|
|
|
|
border = "white", col = "#3CB4DC")
|
|
|
|
text(tmp, counts_item + 1000, datart$artwork)
|
2023-09-26 18:34:59 +02:00
|
|
|
dev.off()
|
|
|
|
|
2024-01-09 17:45:16 +01:00
|
|
|
### Which item gets touched most often first?
|
2023-09-26 18:34:59 +02:00
|
|
|
|
|
|
|
datcase <- datlogs[!duplicated(datlogs$case), ]
|
2024-01-09 17:45:16 +01:00
|
|
|
counts_case <- table(datcase$item)
|
2023-09-26 18:34:59 +02:00
|
|
|
names(counts_case) <- datart$title
|
|
|
|
tmp <- barplot(counts_case, las = 2, border = "white")
|
2024-01-09 17:45:16 +01:00
|
|
|
text(tmp, counts_case + 100, datart$item)
|
2023-09-26 18:34:59 +02:00
|
|
|
|
2024-01-09 17:45:16 +01:00
|
|
|
counts <- rbind(counts_item, counts_case)
|
2023-09-26 18:34:59 +02:00
|
|
|
barplot(counts, las = 2, border = "white", col = c("gray", "darkorange"))
|
|
|
|
|
|
|
|
### Which teasers seem to work well?
|
|
|
|
barplot(table(datlogs$topic), las = 2)
|
|
|
|
|
|
|
|
### Dwell times/duration
|
2024-01-09 17:45:16 +01:00
|
|
|
datagg <- aggregate(duration ~ event + item, datlogs, mean)
|
2023-09-26 18:34:59 +02:00
|
|
|
datagg$ds <- datagg$duration / 1000
|
|
|
|
|
2024-01-09 17:45:16 +01:00
|
|
|
bwplot(ds ~ event, datagg)
|
|
|
|
bwplot(ds ~ event | item, datagg)
|
|
|
|
xyplot(ds ~ event, datagg, groups = item)
|
2023-09-26 18:34:59 +02:00
|
|
|
|
|
|
|
# without aggregation
|
2024-01-09 17:45:16 +01:00
|
|
|
bwplot(duration ~ event, datlogs)
|
2023-09-26 18:34:59 +02:00
|
|
|
# in min
|
|
|
|
|
2023-09-28 15:04:59 +02:00
|
|
|
set.seed(1027)
|
|
|
|
|
2023-09-26 18:39:02 +02:00
|
|
|
pdf("../figures/duration.pdf", width = 5, height = 5, pointsize = 10)
|
2024-01-09 17:45:16 +01:00
|
|
|
bwplot(I(duration/1000/60) ~ event, datlogs[sample(nrow(datlogs), 100000), ],
|
2023-09-28 15:04:59 +02:00
|
|
|
ylab = "Duration in min")
|
2023-09-26 18:39:02 +02:00
|
|
|
dev.off()
|
2023-09-26 18:34:59 +02:00
|
|
|
|
2023-09-29 15:04:11 +02:00
|
|
|
### Move events
|
|
|
|
|
2024-01-09 17:45:16 +01:00
|
|
|
datmove <- aggregate(cbind(duration, scaleSize, rotationDegree, distance, x.start,
|
|
|
|
y.start, x.stop, y.stop) ~ item, datlogs,
|
2023-09-29 15:04:11 +02:00
|
|
|
mean)
|
|
|
|
|
|
|
|
hist(log(datlogs$scaleSize))
|
|
|
|
# --> better interpretable on logscale
|
|
|
|
|
|
|
|
plot(y.start ~ x.start, datmove, pch = 16, col = "gray")
|
2024-01-09 17:45:16 +01:00
|
|
|
points(y.start ~ x.start, datmove, col = "#3CB4DC", cex = datmove$scaleSize)
|
2023-09-29 15:04:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
plot(y.start ~ x.start, datmove, type = "n", xlab = "x", ylab = "y",
|
|
|
|
xlim = c(0, 3840), ylim = c(0, 2160))
|
2024-01-09 17:45:16 +01:00
|
|
|
with(datmove, text(x.start, y.start, item, col = "gray", cex = 1.5))
|
2023-09-29 15:04:11 +02:00
|
|
|
with(datmove,
|
|
|
|
arrows(x.start, y.start, x.stop, y.stop, length = 0.07, lwd = 2)
|
|
|
|
)
|
2024-01-09 17:45:16 +01:00
|
|
|
abline(v = c(0, 3840), h = c(0, 2160), col = "#3CB4DC", lwd = 2)
|
2023-09-29 15:04:11 +02:00
|
|
|
|
2024-01-09 17:45:16 +01:00
|
|
|
datscale <- aggregate(scaleSize ~ item, datlogs, max)
|
2023-09-29 15:04:11 +02:00
|
|
|
plot(y.start ~ x.start, datmove, pch = 16, col = "gray")
|
2024-01-09 17:45:16 +01:00
|
|
|
points(y.start ~ x.start, datmove, col = "#3CB4DC", cex = datscale$scaleSize)
|
2023-09-29 15:04:11 +02:00
|
|
|
|
|
|
|
plot(y.start ~ x.start, datmove, type = "n", xlab = "x", ylab = "y",
|
|
|
|
xlim = c(0, 3840), ylim = c(0, 2160))
|
2024-01-09 17:45:16 +01:00
|
|
|
#with(datmove, text(x.stop, y.stop, item))
|
|
|
|
with(datmove, text(x.start, y.start, item))
|
2023-09-29 15:04:11 +02:00
|
|
|
|
2023-09-26 18:34:59 +02:00
|
|
|
|
|
|
|
### Are there certain areas of the table that are touched most often?
|
|
|
|
|
|
|
|
# heatmap
|
|
|
|
cuts <- 100
|
|
|
|
|
|
|
|
datlogs$x.start.cat <- cut(datlogs$x.start, cuts)
|
|
|
|
datlogs$y.start.cat <- cut(datlogs$y.start, cuts)
|
|
|
|
|
|
|
|
tab <- xtabs( ~ x.start.cat + y.start.cat, datlogs)
|
|
|
|
|
|
|
|
colnames(tab) <- paste0("c", 1:cuts)
|
|
|
|
rownames(tab) <- paste0("c", 1:cuts)
|
|
|
|
|
|
|
|
heatmap(tab, Rowv = NA, Colv = NA)
|
|
|
|
|
|
|
|
|
|
|
|
library(ggplot2)
|
|
|
|
|
|
|
|
ggplot(as.data.frame(tab)) +
|
|
|
|
geom_tile(aes(x = x.start.cat, y = y.start.cat, fill = Freq)) +
|
|
|
|
scale_fill_gradient(low = "gray40", high = "orange")
|
|
|
|
|
|
|
|
dattrim <- datlogs[datlogs$x.start < 3840 &
|
|
|
|
datlogs$x.start > 0 &
|
|
|
|
datlogs$y.start < 2160 &
|
|
|
|
datlogs$y.start > 0 &
|
|
|
|
datlogs$x.stop < 3840 &
|
|
|
|
datlogs$x.stop > 0 &
|
|
|
|
datlogs$y.stop < 2160 &
|
|
|
|
datlogs$y.stop > 0, ]
|
|
|
|
|
2023-09-26 18:39:02 +02:00
|
|
|
cuts <- 100 # 200, 100, 70, ...
|
2023-09-26 18:34:59 +02:00
|
|
|
|
|
|
|
# start
|
|
|
|
dattrim$x.start.cat <- cut(dattrim$x.start, cuts)
|
|
|
|
dattrim$y.start.cat <- cut(dattrim$y.start, cuts)
|
|
|
|
|
|
|
|
tab.start <- xtabs( ~ x.start.cat + y.start.cat, dattrim)
|
2023-09-26 18:39:02 +02:00
|
|
|
colnames(tab.start) <- NULL
|
|
|
|
rownames(tab.start) <- NULL
|
2023-09-26 18:34:59 +02:00
|
|
|
|
2023-09-26 18:39:02 +02:00
|
|
|
pdf("../figures/heatmap_start.pdf", width = 5, height = 5, pointsize = 10)
|
2023-09-26 18:34:59 +02:00
|
|
|
heatmap(tab.start, Rowv = NA, Colv = NA)
|
2023-09-26 18:39:02 +02:00
|
|
|
dev.off()
|
|
|
|
|
|
|
|
|
|
|
|
my_colors <- colorRampPalette(c("#009E73", "#E69F00"))
|
2023-09-26 18:34:59 +02:00
|
|
|
heatmap(tab.start, Rowv = NA, Colv = NA, col = my_colors(1000))
|
|
|
|
|
|
|
|
ggplot(as.data.frame(tab.start)) +
|
|
|
|
geom_tile(aes(x = x.start.cat, y = y.start.cat, fill = Freq)) +
|
2023-09-26 18:39:02 +02:00
|
|
|
scale_fill_gradient(low = "#009E73", high = "#E69F00")
|
2023-09-26 18:34:59 +02:00
|
|
|
|
|
|
|
# stop
|
|
|
|
dattrim$x.stop.cat <- cut(dattrim$x.stop, cuts)
|
|
|
|
dattrim$y.stop.cat <- cut(dattrim$y.stop, cuts)
|
|
|
|
tab.stop <- xtabs( ~ x.stop.cat + y.stop.cat, dattrim)
|
2023-09-26 18:39:02 +02:00
|
|
|
colnames(tab.stop) <- NULL
|
|
|
|
rownames(tab.stop) <- NULL
|
2023-09-26 18:34:59 +02:00
|
|
|
|
2023-09-26 18:39:02 +02:00
|
|
|
pdf("../figures/heatmap_stop.pdf", width = 5, height = 5, pointsize = 10)
|
2023-09-26 18:34:59 +02:00
|
|
|
heatmap(tab.stop, Rowv = NA, Colv = NA)
|
2023-09-26 18:39:02 +02:00
|
|
|
dev.off()
|
|
|
|
|
|
|
|
heatmap(tab.stop, Rowv = NA, Colv = NA, col = my_colors(10))
|
2023-09-26 18:34:59 +02:00
|
|
|
|
|
|
|
### How many visitors per day
|
|
|
|
|
2024-01-09 17:45:16 +01:00
|
|
|
datlogs$date <- as.Date(datlogs$date.start)
|
|
|
|
|
2023-09-26 18:34:59 +02:00
|
|
|
# Interactions per day
|
|
|
|
datint <- aggregate(case ~ date, datlogs, length)
|
|
|
|
plot(datint, type = "h")
|
|
|
|
|
|
|
|
# Cases per day
|
|
|
|
datcase <- aggregate(case ~ date, datlogs, function(x) length(unique(x)))
|
|
|
|
plot(datcase, type = "h")
|
|
|
|
|
2024-01-09 17:45:16 +01:00
|
|
|
# Paths per day
|
|
|
|
datpath <- aggregate(path ~ date, datlogs, function(x) length(unique(x)))
|
|
|
|
plot(datpath, type = "h")
|
2023-09-26 18:34:59 +02:00
|
|
|
|
2024-01-09 17:45:16 +01:00
|
|
|
plot(path ~ date, datpath, type = "h", col = "#3CB4DC")
|
2023-09-26 18:39:02 +02:00
|
|
|
points(case ~ date, datcase, type = "h")
|
2023-09-26 18:34:59 +02:00
|
|
|
|
2024-01-09 17:45:16 +01:00
|
|
|
pdf("../figures/cases_per_day2.pdf", width = 9, height = 5, pointsize = 10)
|
2023-09-26 18:39:02 +02:00
|
|
|
par(mai = c(.6, .6, .1, .1), mgp = c(2.4, 1, 0))
|
2024-01-09 17:45:16 +01:00
|
|
|
plot(case ~ date, datcase, type = "h", col = "#3CB4DC")
|
|
|
|
abline(v = datcase$date[datcase$date %in% c("2020-03-13", "2022-10-25")],
|
|
|
|
col = "#FF6900", lty = 2)
|
|
|
|
text(datcase$date[datcase$date == "2020-03-13"]+470, 80,
|
|
|
|
"Corona gap from 2020-03-13 to 2022-10-25",
|
|
|
|
col = "#D55E00")
|
2023-09-26 18:39:02 +02:00
|
|
|
dev.off()
|
|
|
|
|
|
|
|
|
|
|
|
### Other stuff
|
|
|
|
|
|
|
|
## function dependencies of mtt
|
2023-09-21 16:45:06 +02:00
|
|
|
devtools::load_all("../../../../software/mtt")
|
|
|
|
#library(mtt)
|
|
|
|
|
2023-09-26 18:34:59 +02:00
|
|
|
library(mvbutils)
|
|
|
|
foodweb(where = "package:mtt")
|
|
|
|
|
2023-09-26 18:39:02 +02:00
|
|
|
pdf("../figures/fun_depend_mtt.pdf", width = 8, height = 4, pointsize = 10)
|
2023-09-26 18:34:59 +02:00
|
|
|
foodweb(where = "package:mtt",
|
|
|
|
prune = c("parse_logfiles", "create_eventlogs", "extract_artworks",
|
2024-01-09 17:45:16 +01:00
|
|
|
"extract_topics"),
|
2023-11-10 18:30:15 +01:00
|
|
|
#expand.ybox = 1.8, #cex = .6,
|
|
|
|
#border = TRUE,
|
2023-09-26 18:39:02 +02:00
|
|
|
#boxcolor = "gray",
|
2024-01-09 17:45:16 +01:00
|
|
|
color.lines = FALSE,
|
2023-09-26 18:39:02 +02:00
|
|
|
lwd = 2, mai = c(0, 0, 0, 0))
|
|
|
|
dev.off()
|
2023-09-26 18:34:59 +02:00
|
|
|
|
|
|
|
|
2023-09-26 18:39:02 +02:00
|
|
|
## weird behavior of timeMs
|
2023-09-26 18:34:59 +02:00
|
|
|
|
2023-09-26 18:39:02 +02:00
|
|
|
pdf("../figures/timeMs.pdf", width = 9, height = 6, pointsize = 10)
|
|
|
|
#par(mai = c(.6, .6, .1, .1), mgp = c(2.4, 1, 0))
|
|
|
|
#plot(timeMs.start ~ as.factor(fileId), datlogs[1:2000,], xlab = "fileId")
|
2024-01-09 17:45:16 +01:00
|
|
|
bwplot(timeMs.start ~ as.factor(fileId.start), datlogs[1:2000,], xlab = "",
|
2023-09-26 18:39:02 +02:00
|
|
|
scales = list(x = list(rot = 90), y = list(rot = 90)))
|
|
|
|
dev.off()
|
2023-09-26 18:34:59 +02:00
|
|
|
|
2023-09-26 18:39:02 +02:00
|
|
|
## x,y-coordinates out of range
|
2023-09-26 18:34:59 +02:00
|
|
|
|
2023-09-26 18:39:02 +02:00
|
|
|
set.seed(1522)
|
2023-09-26 18:34:59 +02:00
|
|
|
|
2023-09-26 18:39:02 +02:00
|
|
|
pdf("../figures/xycoord.pdf", width = 5, height = 5, pointsize = 10)
|
|
|
|
par(mai = c(.6, .6, .1, .1), mgp = c(2.4, 1, 0))
|
|
|
|
#par(mfrow = c(1, 2))
|
|
|
|
plot(y.start ~ x.start, datlogs[sample(nrow(datlogs), 10000), ])
|
2024-01-09 17:45:16 +01:00
|
|
|
abline(v = c(0, 3840), h = c(0, 2160), col = "#3CB4DC", lwd = 2)
|
2023-09-26 18:39:02 +02:00
|
|
|
#plot(y.stop ~ x.stop, datlogs)
|
2024-01-09 17:45:16 +01:00
|
|
|
#abline(v = c(0, 3840), h = c(0, 2160), col = "#3CB4DC", lwd = 2)
|
2023-09-26 18:39:02 +02:00
|
|
|
legend("bottomleft", "Random sample of 10,000", bg = "white")
|
|
|
|
legend("topleft", "4K-Display: 3840 x 2160", bg = "white")
|
|
|
|
dev.off()
|
2023-09-26 18:34:59 +02:00
|
|
|
|
2023-09-26 18:39:02 +02:00
|
|
|
## moves
|
2023-09-21 16:45:06 +02:00
|
|
|
|
2024-01-09 17:45:16 +01:00
|
|
|
dat001 <- datlogs[which(datlogs$item == "001"), ]
|
2023-09-21 16:45:06 +02:00
|
|
|
|
2024-01-09 17:45:16 +01:00
|
|
|
index <- as.numeric(as.factor(dat001$path))
|
2023-09-26 18:34:59 +02:00
|
|
|
cc <- sample(colors(), 100)
|
2023-09-21 16:45:06 +02:00
|
|
|
|
|
|
|
plot(y.start ~ x.start, dat001, type = "n", xlab = "x", ylab = "y",
|
|
|
|
xlim = c(0, 3840), ylim = c(0, 2160))
|
|
|
|
with(dat001[1:200,], arrows(x.start, y.start, x.stop, y.stop,
|
|
|
|
length = .07, col = cc[index]))
|
|
|
|
|
|
|
|
plot(y.start ~ x.start, dat001, xlab = "x", ylab = "y",
|
|
|
|
xlim = c(0, 3840), ylim = c(0, 2160), pch = 16, col = "gray")
|
|
|
|
points(y.start ~ x.start, dat001, xlab = "x", ylab = "y",
|
|
|
|
xlim = c(0, 3840), ylim = c(0, 2160), cex = dat001$scaleSize,
|
|
|
|
col = "blue")
|
|
|
|
|
|
|
|
|
2023-09-26 18:34:59 +02:00
|
|
|
|
|
|
|
cc <- sample(colors(), 70)
|
|
|
|
|
2024-01-09 17:45:16 +01:00
|
|
|
dat1 <- datlogs[!duplicated(datlogs$item), ]
|
|
|
|
dat1 <- dat1[order(dat1$item), ]
|
2023-09-26 18:34:59 +02:00
|
|
|
|
|
|
|
plot(y.start ~ x.start, dat1, type = "n", xlim = c(-100, 4500), ylim = c(-100, 2500))
|
|
|
|
abline(h = c(0, 2160), v = c(0, 3840), col = "lightgray")
|
|
|
|
with(dat1, points(x.start, y.start, col = cc, pch = 16))
|
|
|
|
with(dat1, points(x.stop, y.stop, col = cc, pch = 16))
|
|
|
|
with(dat1, arrows(x.start, y.start, x.stop, y.stop, length = .07, col = cc))
|
|
|
|
|