71 lines
3.7 KiB
R
71 lines
3.7 KiB
R
#trying to make a time plot showing the over-time shift
|
|
library(plyr)
|
|
contrib_df <- read_csv('../final_data/deb_contrib_did.csv')
|
|
readme_df <- read_csv("../final_data/deb_readme_did.csv")
|
|
col_order <- c("upstream_vcs_link", "age_in_days", "first_commit", "first_commit_dt", "event_gap", "event_date", "event_hash", "before_all_ct", "after_all_ct", "before_mrg_ct", "after_mrg_ct", "before_auth_new", "after_auth_new", "before_commit_new", "after_commit_new")
|
|
#first contrib
|
|
contrib_df <- contrib_df[,col_order]
|
|
contrib_df$ct_before_all <- str_split(gsub("[][]","", contrib_df$before_all_ct), ", ")
|
|
contrib_df$ct_after_all <- str_split(gsub("[][]","", contrib_df$after_all_ct), ", ")
|
|
contrib_df$ct_before_mrg <- str_split(gsub("[][]","", contrib_df$before_mrg_ct), ", ")
|
|
contrib_df$ct_after_mrg <- str_split(gsub("[][]","", contrib_df$after_mrg_ct), ", ")
|
|
drop <- c("before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct")
|
|
contrib_df = contrib_df[,!(names(contrib_df) %in% drop)]
|
|
#then readme
|
|
readme_df <- readme_df[,col_order]
|
|
readme_df$ct_before_all <- str_split(gsub("[][]","", readme_df$before_all_ct), ", ")
|
|
readme_df$ct_after_all <- str_split(gsub("[][]","", readme_df$after_all_ct), ", ")
|
|
readme_df$ct_before_mrg <- str_split(gsub("[][]","", readme_df$before_mrg_ct), ", ")
|
|
readme_df$ct_after_mrg <- str_split(gsub("[][]","", readme_df$after_mrg_ct), ", ")
|
|
drop <- c("before_all_ct", "before_mrg_ct", "after_all_ct", "after_mrg_ct")
|
|
readme_df = readme_df[,!(names(readme_df) %in% drop)]
|
|
# 2 some expansion needs to happens for each project
|
|
expand_timeseries <- function(project_row) {
|
|
longer <- project_row |>
|
|
pivot_longer(cols = starts_with("ct"),
|
|
names_to = "window",
|
|
values_to = "count") |>
|
|
unnest(count)
|
|
longer$observation_type <- gsub("^.*_", "", longer$window)
|
|
longer <- ddply(longer, "observation_type", transform, week=seq(from=0, by=1, length.out=length(observation_type)))
|
|
longer$count <- as.numeric(longer$count)
|
|
#longer <- longer[which(longer$observation_type == "all"),]
|
|
return(longer)
|
|
}
|
|
expanded_contrib_data <- expand_timeseries(contrib_df[1,])
|
|
for (i in 2:nrow(contrib_df)){
|
|
expanded_contrib_data <- rbind(expanded_contrib_data, expand_timeseries(contrib_df[i,]))
|
|
}
|
|
expanded_readme_data <- expand_timeseries(readme_df[1,])
|
|
for (i in 2:nrow(readme_df)){
|
|
expanded_readme_data <- rbind(expanded_readme_data, expand_timeseries(readme_df[i,]))
|
|
}
|
|
window_num <- 8
|
|
windowed_contrib_data <- expanded_contrib_data |>
|
|
filter(week >= (27 - window_num) & week <= (27 + window_num)) |>
|
|
mutate(D = ifelse(week > 27, 1, 0))
|
|
windowed_readme_data <- expanded_readme_data |>
|
|
filter(week >= (27 - window_num) & week <= (27 + window_num)) |>
|
|
mutate(D = ifelse(week > 27, 1, 0))
|
|
|
|
windowed_contrib_data$week_offset <- windowed_contrib_data$week - 27
|
|
all_actions_contrib_data <- windowed_contrib_data[which(windowed_contrib_data$observation_type == "all"),]
|
|
all_actions_contrib_data$document_type <- rep("contributing", length(all_actions_contrib_data$count))
|
|
windowed_readme_data$week_offset <- windowed_readme_data$week - 27
|
|
all_actions_readme_data <- windowed_readme_data[which(windowed_readme_data$observation_type == "all"),]
|
|
all_actions_readme_data$document_type <- rep("readme", length(all_actions_readme_data$count))
|
|
all_actions_data <- rbind(all_actions_contrib_data, all_actions_readme_data)
|
|
all_actions_data$log1p_count <- log1p(all_actions_data$count)
|
|
time_plot <- all_actions_data |>
|
|
ggplot(aes(x=week_offset, y=log1p_count, color=factor(document_type))) +
|
|
geom_smooth() +
|
|
geom_vline(xintercept = 0)+
|
|
theme_bw() +
|
|
theme(legend.position = "top")
|
|
time_plot
|
|
#looking at event gap
|
|
mean(all_actions_readme_data$event_gap)
|
|
sd(all_actions_readme_data$event_gap)
|
|
mean(all_actions_contrib_data$event_gap)
|
|
sd(all_actions_contrib_data$event_gap)
|