1
0
mw-lifecycle-analysis/commit_analysis/commit_plotting.R
2025-02-20 15:44:54 -08:00

54 lines
2.0 KiB
R

library(tidyverse)
count_data_fp <-"/mmfs1/gscratch/comdata/users/mjilg/mw-repo-lifecycles/case1/event_0217_extensions_ve_weekly_commit_count_data.csv"
input_df <- read.csv(count_data_fp, header = TRUE)
input_df$nonbot_commit_count <- input_df$commit_count - input_df$bot_commit_count
window_num <- 52
input_df <- input_df |>
filter(relative_week >= (- window_num) & relative_week <= (window_num)) |>
mutate(nonbot_commit_count = commit_count - bot_commit_count)|>
mutate(other_commit_count = nonbot_commit_count - mediawiki_dev_commit_count - wikia_commit_count - wikimedia_commit_count) |>
mutate(wikimedia_commit_count = wikimedia_commit_count + mediawiki_dev_commit_count + wikia_commit_count) |>
select(-mediawiki_dev_commit_count) |>
select(-wikia_commit_count)
library(scales)
library(ggplot2)
time_plot <- input_df |>
ggplot(aes(x=relative_week, y=nonbot_commit_count)) +
labs(x="Weekly Offset", y="Nonbot Commit Count") +
geom_smooth() +
geom_vline(xintercept = 0)+
theme_bw() +
theme(legend.position = "top")
time_plot
library(dplyr)
share_df <- input_df |>
mutate(wikimedia_share = wikimedia_commit_count / nonbot_commit_count) |>
mutate(other_share = other_commit_count / nonbot_commit_count)|>
drop_na()
share_long <- share_df |>
dplyr::select(relative_week, wikimedia_share, other_share) |>
pivot_longer(cols = c(wikimedia_share, other_share), names_to = "category", values_to = "share")
share_plot <- share_long |>
ggplot(aes(x=relative_week, y=share, color=category)) +
geom_line() +
geom_vline(xintercept = 0)+
annotate("text", x = -7, y=1, label = "2012-12-12") +
geom_vline(xintercept = 19)+
annotate("text", x = 12, y=1, label = "2013-04-28") +
geom_vline(xintercept = 28)+
annotate("text", x = 35, y=1, label = "2013-07-01") +
labs(x = "Relative Week", y = "Share of Nonbot Commit Count", color = "Affiliation") +
ggtitle("VE Weekly Share of Nonbot Commit Count by Affiliation (enwiki opt-in testing 2012-12-12)") +
theme_bw() +
theme(legend.position = "top")
share_plot