1
0
mw-lifecycle-analysis/commit_analysis/testing-share-plotting.R
2025-03-14 09:18:18 -07:00

102 lines
4.4 KiB
R

library(tidyverse)
entest_fp <-"/mmfs1/gscratch/comdata/users/mjilg/mw-repo-lifecycles/case1/en-testing_0312_mediawiki_core_weekly_commit_count_data.csv"
entest_df <- read.csv(entest_fp, header = TRUE) |> mutate(rd_event = "en-testing")
widetest_fp <-"/mmfs1/gscratch/comdata/users/mjilg/mw-repo-lifecycles/case1/wide-testing_0312_mediawiki_core_weekly_commit_count_data.csv"
widetest_df <- read.csv(widetest_fp, header = TRUE) |> mutate(rd_event = "wide-testing")
event_fp <-"/mmfs1/gscratch/comdata/users/mjilg/mw-repo-lifecycles/case1/event_0312_mediawiki_core_weekly_commit_count_data.csv"
event_df <- read.csv(event_fp, header = TRUE) |> mutate(rd_event = "default")
#input_df <- bind_rows(entest_df, widetest_df, event_df)
#dropping the event (2013-07-01) from the modeling
input_df <- bind_rows(entest_df, widetest_df)
#input_df <- event_df
input_df <- input_df |>
mutate(nonbot_commit_count = commit_count - bot_commit_count)|>
mutate(other_commit_count = nonbot_commit_count - mediawiki_dev_commit_count - wikimedia_commit_count) |>
mutate(wikimedia_commit_count = wikimedia_commit_count + mediawiki_dev_commit_count) |>
dplyr::select(-mediawiki_dev_commit_count) |>
dplyr::select(-wikia_commit_count)
#get into mlm format
long_df <- input_df |>
tidyr::pivot_longer(cols = c(other_commit_count, wikimedia_commit_count),
names_to = "commit_type",
values_to = "lengthened_commit_count")
#long_df <- input_df |>
# tidyr::pivot_longer(cols = c(wmf_ft_commit_count, unaff_ft_commit_count, nonbot_commit_count),
# names_to = "commit_type",
# values_to = "lengthened_commit_count")
intermediate_long_df <- long_df |>
mutate(commit_share = lengthened_commit_count / (nonbot_commit_count)) |>
mutate(log_commits = log1p(lengthened_commit_count))|>
mutate(scaled_long_commits = lengthened_commit_count / 10)
window_num <- 4
final_long_df <- intermediate_long_df |>
filter(relative_week >= (- window_num) & relative_week <= (window_num))
affiliationColors <-
setNames( c('#5da2d8', '#c7756a')
,c("other_commit_count", "wikimedia_commit_count"))
commit_plot <- final_long_df |>
ggplot(aes(x=relative_week,
y=lengthened_commit_count,
color=factor(commit_type),
linetype = rd_event)) +
geom_line() +
geom_point() +
labs(x = "Relative Week", y = "Commits", linetype = "Testing Event", color="Commit Author Affiliation") +
scale_color_manual(values = affiliationColors,
labels = c("other_commit_count" = "Unaffiliated", "wikimedia_commit_count" = "WMF Affiliated")) +
scale_linetype_discrete(labels = c("enwiki testing (2012-12-11)", "wide testing (2013-04-25)")) +
ggtitle("mw-core Commits Around Opt-In Testing Events (by Affiliation)") +
theme_bw() +
theme(legend.position = "top")
commit_plot
ggsave(filename = "0314-ve-core-testing-new-commits.png", plot = commit_plot, width = 15, height = 9, dpi = 800)
total_commit_plot <- final_long_df |>
ggplot(aes(x=relative_week,
y=nonbot_commit_count,
linetype = rd_event)) +
geom_line() +
geom_point() +
geom_vline(xintercept = 0, linetype = "dotted", color = "black") +
labs(x = "Relative Week", y = "Nonbot Commit Count", linetype = "Testing Event") +
scale_linetype_discrete(labels = c("enwiki testing (2012-12-12)", "wide testing (2013-04-25)")) +
ggtitle("VisualEditor Weekly Nonbot Commits Surrounding Opt-In Testing Events") +
theme_bw() +
theme(legend.position = "top")
total_commit_plot
ggsave(filename = "0305-ve-total-commits.png", plot = total_commit_plot, width = 15, height = 9, dpi = 800)
commit_share_plot <- final_long_df |>
ggplot(aes(x=relative_week,
y=commit_share,
color=commit_type,
linetype = rd_event)) +
geom_line() +
geom_point() +
labs(x = "Relative Week", y = "Share of Nonbot Commits", linetype = "Testing Event", color="Commit Author Affiliation") +
scale_color_manual(values = affiliationColors,
labels = c("other_commit_count" = "Unaffiliated", "wikimedia_commit_count" = "WMF Affiliated")) +
scale_linetype_discrete(labels = c("enwiki testing (2012-12-12)", "wide testing (2013-04-25)")) +
ggtitle("Share of Weekly VisualEditor Commits Surrounding Opt-in Testing Events") +
theme_bw() +
theme(legend.position = "top")
commit_share_plot
ggsave(filename = "0312-ve-ve-testing-share.png", plot = commit_share_plot, width = 12, height = 9, dpi = 800)