1
0
mw-lifecycle-analysis/commit_analysis/testing-share-plotting.R
2025-03-01 17:08:16 -08:00

83 lines
3.7 KiB
R

library(tidyverse)
entest_fp <-"/mmfs1/gscratch/comdata/users/mjilg/mw-repo-lifecycles/case1/en-testing_0217_extensions_ve_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_0217_extensions_ve_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_0217_extensions_ve_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 <- 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)
#get into mlm format
long_df <- input_df |>
pivot_longer(cols = c(other_commit_count, wikimedia_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)
intermediate_long_df <- intermediate_long_df |>
drop_na()
window_num <- 4
final_long_df <- intermediate_long_df |>
filter(relative_week >= (- window_num) & relative_week <= (window_num))
commit_plot <- final_long_df |>
ggplot(aes(x=relative_week,
y=lengthened_commit_count,
color=commit_type,
linetype = rd_event)) +
geom_line() +
geom_point() +
labs(x = "Relative Week", y = "Nonbot Commits", linetype = "Testing Event", color="Commit Author Affiliation") +
scale_linetype_discrete(labels = c("enwiki testing (2012-12-12)", "wide testing (2013-04-25)")) +
scale_color_discrete(labels = c("Unaffiliated", "Organizationally Affiliated")) +
ggtitle("VisualEditor Nonbot Commit Count Around Opt-In Testing Events (by Affiliation)") +
theme_bw() +
theme(legend.position = "top")
commit_plot
total_commit_plot <- final_long_df |>
filter(commit_type == "other_commit_count")|>
ggplot(aes(x=relative_week,
y=nonbot_commit_count,
linetype = rd_event)) +
geom_line() +
geom_point() +
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 Nonbot Commit Count Around Opt-In Testing Events") +
theme_bw() +
theme(legend.position = "top")
total_commit_plot
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_linetype_discrete(labels = c("enwiki testing (2012-12-12)", "wide testing (2013-04-25)")) +
scale_color_discrete(labels = c("Unaffiliated", "Organizationally Affiliated")) +
ggtitle("VisualEditor Nonbot Commit Share Around Opt-In Testing Events") +
theme_bw() +
theme(legend.position = "top")
commit_share_plot