1
0
mw-lifecycle-analysis/commit_analysis/commit_plotting.R
2025-03-05 09:20:11 -08:00

51 lines
1.9 KiB
R

library(tidyverse)
count_data_fp <-"/mmfs1/gscratch/comdata/users/mjilg/mw-repo-lifecycles/case1/en-testing_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 <- 12
intermediate_df <- input_df |>
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) |>
dplyr::select(-mediawiki_dev_commit_count) |>
dplyr::select(-wikia_commit_count) |>
filter(relative_week >= (- window_num) & relative_week <= (window_num))
library(scales)
library(ggplot2)
time_plot <- intermediate_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 <- intermediate_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")
commit_share_plot <- share_long |>
ggplot(aes(x=relative_week,
y=share,
color=category)) +
geom_line() +
geom_point() +
labs(x = "Relative Week", y = "Share of Nonbot Commits", color="Commit Author Affiliation") +
scale_color_discrete(labels = c("Unaffiliated", "Organizationally Affiliated")) +
ggtitle("VisualEditor Nonbot Commit Share Around Opt-out Deployment") +
theme_bw() +
theme(legend.position = "top")
commit_share_plot