2024-06-28 04:40:08 +00:00
|
|
|
#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"),]
|
2024-08-24 22:04:46 +00:00
|
|
|
all_actions_contrib_data$document_type <- rep("CONTRIBUTING", length(all_actions_contrib_data$count))
|
2024-06-28 04:40:08 +00:00
|
|
|
windowed_readme_data$week_offset <- windowed_readme_data$week - 27
|
|
|
|
all_actions_readme_data <- windowed_readme_data[which(windowed_readme_data$observation_type == "all"),]
|
2024-08-24 22:04:46 +00:00
|
|
|
all_actions_readme_data$document_type <- rep("README", length(all_actions_readme_data$count))
|
2024-06-28 04:40:08 +00:00
|
|
|
all_actions_data <- rbind(all_actions_contrib_data, all_actions_readme_data)
|
|
|
|
all_actions_data$log1p_count <- log1p(all_actions_data$count)
|
2024-08-24 22:04:46 +00:00
|
|
|
library(scales)
|
|
|
|
expm1_trans <- trans_new(
|
|
|
|
name = 'expm1',
|
|
|
|
transform = function(x) expm1(x),
|
|
|
|
inverse = function(x) log1p(x)
|
|
|
|
)
|
|
|
|
|
|
|
|
doctypeColors <-
|
|
|
|
setNames( c('#5da2d8', '#c7756a')
|
|
|
|
, c("CONTRIBUTING", "README"))
|
|
|
|
|
2024-06-28 04:40:08 +00:00
|
|
|
time_plot <- all_actions_data |>
|
2024-08-24 22:04:46 +00:00
|
|
|
ggplot(aes(x=week_offset, y=log1p_count, color=factor(document_type))) +
|
|
|
|
labs(x="Weekly Offset", y="Commit Count", color="Document Type") +
|
|
|
|
scale_color_manual(values = doctypeColors) +
|
2024-06-28 04:40:08 +00:00
|
|
|
geom_smooth() +
|
|
|
|
geom_vline(xintercept = 0)+
|
|
|
|
theme_bw() +
|
|
|
|
theme(legend.position = "top")
|
|
|
|
time_plot
|
2024-08-24 22:04:46 +00:00
|
|
|
#code to change the axes
|
|
|
|
|
|
|
|
#scale_y_continuous(breaks = c(0, 0.5, 1.0, 1.5),
|
|
|
|
# labels = round(c(expm1(0), expm1(0.5), expm1(1.0), expm1(1.5)), 1)) +
|
|
|
|
|
2024-06-28 04:40:08 +00:00
|
|
|
#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)
|
2024-08-24 22:04:46 +00:00
|
|
|
|
|
|
|
#all_actions_contrib_data$log1p_count <- log1p(all_actions_contrib_data$count)
|
|
|
|
#contrib_time_plot <- all_actions_contrib_data |>
|
|
|
|
# ggplot(aes(x=week_offset, y=log1p_count)) +
|
|
|
|
# geom_smooth(color=forestgreen) +
|
|
|
|
# geom_vline(xintercept = 0)+
|
|
|
|
# annotate("text", x=3, y=1, label="CONTRIBUTING.md Publication", angle=0)+
|
|
|
|
# theme_bw() +
|
|
|
|
# ylab("Log Transformed Count of Contributions") +
|
|
|
|
# xlab("Offset Weeks") +
|
|
|
|
# theme(legend.position = "top")
|
|
|
|
#contrib_time_plot
|
|
|
|
|