diff --git a/code/10_user-navigation.R b/code/10_user-navigation.R index 18f03b6..118e0c1 100644 --- a/code/10_user-navigation.R +++ b/code/10_user-navigation.R @@ -8,7 +8,7 @@ # input: results/haum/event_logfiles_2024-02-21_16-07-33.csv # output: results/haum/eventlogs_pre-corona_case-clusters.csv # -# last mod: 2024-03-08 +# last mod: 2024-03-14 # setwd("C:/Users/nwickelmaier/Nextcloud/Documents/MDS/2023ss/60100_master_thesis/analysis/code") @@ -52,17 +52,19 @@ hc <- hcs$ward k <- 5 -mycols <- c("#434F4F", "#78004B", "#FF6900", "#3CB4DC", "#91C86E") +mycols <- c("#3CB4DC", "#FF6900", "#78004B", "#91C86E", "#434F4F") cluster <- cutree(as.hclust(hc), k = k) table(cluster) -plot(coor_2d, col = mycols[cluster]) -legend("topleft", paste("Cl", 1:4), col = mycols, pch = 21) +plot(coor_2d, col = mycols[cluster], pch = 16) +#legend("topleft", paste("Cl", 1:5), col = mycols, pch = 21) +legend("topleft", c("Scanning", "Exploring", "Flitting", "Searching", "Info"), + col = mycols, bty = "n", pch = 16) rgl::plot3d(coor_3d, col = mycols[cluster]) -ftable(xtabs( ~ InfocardOnly + Pattern + cluster, dattree)) +print(ftable(xtabs( ~ InfocardOnly + Pattern + cluster, dattree)), zero = "-") aggregate(. ~ cluster, df, mean) @@ -124,6 +126,10 @@ write.table(res, save(res, dist_mat, hcs, acs, coor_2d, coor_3d, file = "results/haum/tmp_user-navigation.RData") +save(coor_2d, coor_3d, cluster, + file = "../../thesis/figures/data/clustering_cases.RData") + + #--------------- (3) Fit tree --------------- c1 <- rpart::rpart(as.factor(cluster) ~ ., data = dattree[, c("PropMoves", @@ -134,8 +140,8 @@ c1 <- rpart::rpart(as.factor(cluster) ~ ., data = dattree[, c("PropMoves", "InfocardOnly")], method = "class") -pdf("results/figures/tree_items_rpart.pdf", height = 5, width = 15, pointsize = 10) -plot(partykit::as.party(c1)) +pdf("results/figures/tree_cases_rpart.pdf", height = 5, width = 15, pointsize = 10) +plot(partykit::as.party(c1), tp_args = list(fill = mycols, col = mycols)) dev.off() # with conditional tree @@ -147,7 +153,20 @@ c2 <- partykit::ctree(as.factor(cluster) ~ ., data = dattree[, c("PropMoves", "InfocardOnly")], alpha = 0.001) -pdf("results/figures/tree_items_ctree.pdf", height = 7, width = 20, pointsize = 10) -plot(c2) +pdf("results/figures/tree_cases_ctree.pdf", height = 7, width = 20, pointsize = 10) +plot(c2, tp_args = list(fill = mycols, col = mycols)) dev.off() + + + +factoextra::fviz_dend(as.hclust(hc), k = k, + cex = 0.5, + k_colors = mycols, + #type = "phylogenic", + rect = TRUE, + main = "", + ylab = "" + #ggtheme = ggplot2::theme_bw() +) +