diff --git a/data/transcript_freq_study.R b/data/transcript_freq_study.R index ed7d4f0..c747908 100644 --- a/data/transcript_freq_study.R +++ b/data/transcript_freq_study.R @@ -6,8 +6,8 @@ library(dplyr) #------ messages <- read.csv2("transcript/minecraft_data-1659808309634.csv", sep = ",") messages <- messages %>% mutate( - start_time = as.POSIXct(strptime(start_time, "%Y-%m-%d %T")), - end_time = as.POSIXct(strptime(end_time, "%Y-%m-%d %T")) + start_time = as.POSIXct(strptime(start_time, "%F %T")), + end_time = as.POSIXct(strptime(end_time, "%F %T")) ) n_m <- nrow(messages) @@ -20,16 +20,26 @@ ggplot(messages %>% transmute(tdiff = difftime(start_time, lag(start_time), unit stat_ecdf(data=data.frame(tdiff=rlomax(n_m*10, 1/(b_p + len), (a_p + n_m))), color="red") +ggplot(messages %>% transmute(tdiff = as.numeric(difftime(start_time, lag(start_time)), units = "secs")), aes(x=tdiff)) + theme_minimal() + + geom_histogram(binwidth = 10) + + geom_vline(xintercept = qdiff) + +ggplot(messages, aes(x=start_time)) + theme_minimal() + geom_vline(aes(xintercept=start_time)) + geom_histogram(binwidth = 3600) + +ggplot(messages %>% mutate(tdiff = difftime(start_time, lag(start_time), units = "secs")), aes(x=start_time, y=tdiff)) + theme_minimal() + + geom_point() + + geom_hline(yintercept = qdiff) + #------- # Print messages -for(i in 1:nrow(fmess)) { - line = fmess[i,] +for(i in 1:nrow(messages)) { + line = messages[i,] - cat(sprintf("[%s] <%s> %s\n", line$pub_time, line$nick, line$message)) + cat(sprintf("[%s] <%s> %s\n", line$start_time, line$names, line$transcription_line)) - if(difftime(fmess[i+1,"pub_time"], line$pub_time, units = "secs") > qdiff) + if(difftime(messages[i+1,"start_time"], line$start_time, units = "secs") > qdiff + 20) cat("----------------------\n") } @@ -72,9 +82,30 @@ ggplot(messages, aes(x=start_time)) + theme_minimal() + #--------------- # Diff with 0.01 quantile -qdiff <- qlomax(0.01, 1/(b_p + len), (a_p + n_m)) +qdiff <- qlomax(0.02, 1/(b_p + len), (a_p + n_m)) fmess <- messages %>% filter( - as.numeric(difftime(pub_time, lag(pub_time), units = "secs")) < qdiff | - as.numeric(difftime(lead(pub_time), pub_time, units = "secs")) < qdiff + as.numeric(difftime(start_time, lag(start_time), units = "secs")) < qdiff | + as.numeric(difftime(lead(start_time), start_time, units = "secs")) < qdiff ) + +#---------------- + +ggplot(messages %>% mutate(len = as.double(difftime(end_time, start_time, unit="secs"))), aes(x=len)) + geom_histogram(binwidth = 0.5) + +ggplot(messages[1:50,], aes(xmin=start_time, xmax=end_time, ymin=-1, ymax = 1)) + theme_minimal() + geom_rect() + +#--------- + +last <- 1 +for (i in 2:nrow(messages)) { + if (messages[i,]$start_time == messages[last,]$end_time) { + messages[last,]$transcription_line <- paste(messages[last,]$transcription_line, messages[i,]$transcription_line) + messages[last,]$end_time <- messages[i,]$end_time + messages[i,]$transcription_line <- NA + } else { + last <- i + } +} +messages <- messages %>% filter(!is.na(transcription_line)) +messages %>% transmute(touch = start_time == lag(end_time))