# plotting contributing reading ease contributing_reading_ease <- ggplot(contributing_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + theme(legend.position = "top") + xlim(-10, 90) + theme_bw() contributing_reading_ease grid.arrange(contributing_reading_ease, contributing_linsear_plot, contributing_mcalpine_eflaw, contributing_reading_time_plot, nrow = 2) # plotting contributing mcalpine eflaw contributing_mcalpine_eflaw <- ggplot(contributing_df, aes(x=mcalpine_eflaw, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 70) + guides(fill="none")+ theme_bw() # plotting contributing reading ease contributing_reading_ease <- ggplot(contributing_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + theme(legend.position = "top") + xlim(-10, 90) + theme_bw() contributing_reading_ease grid.arrange(contributing_reading_ease, contributing_linsear_plot, contributing_mcalpine_eflaw, contributing_reading_time_plot, nrow = 2) # plotting contributing mcalpine eflaw contributing_mcalpine_eflaw <- ggplot(contributing_df, aes(x=mcalpine_eflaw, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 70) + guides(fill="none", color="none")+ theme_bw() # plotting contributing reading ease contributing_reading_ease <- ggplot(contributing_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + theme(legend.position = "top") + xlim(-10, 90) + theme_bw() contributing_reading_ease grid.arrange(contributing_reading_ease, contributing_linsear_plot, contributing_mcalpine_eflaw, contributing_reading_time_plot, nrow = 2) # plotting contributing linsear writing formula contributing_linsear_plot <- ggplot(contributing_df, aes(x=linsear_write_formula, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-30, 30) + guides(fill="none", color="none")+ theme_bw() # plotting contributing reading time contributing_reading_time_plot <- ggplot(contributing_df, aes(x=reading_time, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 90) + guides(fill="none", color="none")+ theme_bw() # plotting contributing mcalpine eflaw contributing_mcalpine_eflaw <- ggplot(contributing_df, aes(x=mcalpine_eflaw, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 70) + guides(fill="none", color="none")+ theme_bw() # plotting contributing reading ease contributing_reading_ease <- ggplot(contributing_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 90) + theme_bw(legend.position = "top") contributing_reading_ease # plotting contributing reading ease contributing_reading_ease <- ggplot(contributing_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 90) + theme_bw(legend.position = "left") # plotting contributing reading ease contributing_reading_ease <- ggplot(contributing_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 90) + theme(legend.position = "left") contributing_reading_ease # plotting contributing reading ease contributing_reading_ease <- ggplot(contributing_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 90) + theme(legend.position = "left") + theme_bw() contributing_reading_ease # plotting contributing reading ease contributing_reading_ease <- ggplot(contributing_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 90) + theme_bw(legend.position = "left") contributing_reading_ease # plotting contributing reading ease contributing_reading_ease <- ggplot(contributing_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 90) + opts(legend.position = "left") + theme_bw() # plotting contributing reading ease contributing_reading_ease <- ggplot(contributing_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 90) + theme(legend.position = "left") + theme_bw() contributing_reading_ease # plotting contributing reading ease contributing_reading_ease <- ggplot(contributing_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 90) + theme_bw() + theme(legend.position = "left") contributing_reading_ease # plotting contributing reading ease contributing_reading_ease <- ggplot(contributing_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 90) + theme_bw() + theme(legend.position = "top") contributing_reading_ease grid.arrange(contributing_reading_ease, contributing_linsear_plot, contributing_mcalpine_eflaw, contributing_reading_time_plot, nrow = 2) readme_reading_ease <- ggplot(readme_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 90) + theme_bw() + theme(legend.position = "top") readme_reading_ease #plotting readme reading ease readme_reading_ease <- ggplot(readme_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 90) + theme_bw() + theme(legend.position = "top") #plotting readme reading time readme_reading_time_plot <- ggplot(readme_df, aes(x=reading_time, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 90) + guides(fill="none", color="none")+ theme_bw() grid.arrange(readme_reading_ease, readme_reading_time, contributing_reading_ease, contributing_reading_time_plot, nrow = 2) grid.arrange(readme_reading_ease, readme_reading_time_plot, contributing_reading_ease, contributing_reading_time_plot, nrow = 2) grid.arrange(contributing_reading_ease, contributing_reading_time_plot,readme_reading_ease, readme_reading_time_plot, nrow = 2) # establishing the color scheme irisColors <- setNames( c('red', 'forestgreen', 'blue') , levels(contributing_df$subdir) ) # establishing the color scheme subdirColors <- setNames( c('red', 'forestgreen', 'blue') , levels(contributing_df$subdir) ) # plotting contributing reading ease contributing_reading_ease <- ggplot(contributing_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-10, 90) + theme_bw() + theme(legend.position = "top") contributing_reading_ease #plotting readme reading time readme_reading_time_plot <- ggplot(readme_df, aes(x=reading_time, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-10, 90) + guides(fill="none", color="none")+ theme_bw() #plot of reading_ease #readme_df <- readme_df |> # mutate(coef_grouping <- as.factor(subdir)) #test_lm <- lm(mcalpine_eflaw ~ word_count + as.factor(subdir),data=readme_df) #summary(test_lm) aggregate(contributing_df[, 3:10], list(contributing_df$subdir), median) readme_reading_time_plot #plotting readme reading ease readme_reading_ease <- ggplot(readme_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-10, 90) + theme_bw() + theme(legend.position = "top") readme_reading_ease #plotting readme reading ease readme_reading_ease <- ggplot(readme_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-10, 90) + guides(fill="none", color="none")+ theme_bw() #plotting readme reading time readme_reading_time_plot <- ggplot(readme_df, aes(x=reading_time, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-10, 90) + guides(fill="none", color="none")+ theme_bw() + theme(axis.text.y=element_blank()) readme_reading_time_plot #plotting readme reading time readme_reading_time_plot <- ggplot(readme_df, aes(x=reading_time, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-10, 90) + guides(fill="none", color="none")+ theme_bw(axis.text.y=element_blank()) + theme(axis.text.y=element_blank()) readme_reading_time_plot #plotting readme reading time readme_reading_time_plot <- ggplot(readme_df, aes(x=reading_time, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-10, 100) + guides(fill="none", color="none")+ theme_bw() + theme(axis.text.y=element_blank()) readme_reading_time_plot #plotting readme reading time readme_reading_time_plot <- ggplot(readme_df, aes(x=reading_time, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-10, 110) + guides(fill="none", color="none")+ theme_bw() + theme(axis.text.y=element_blank()) readme_reading_time_plot #plotting readme reading time readme_reading_time_plot <- ggplot(readme_df, aes(x=reading_time, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-10, 140) + guides(fill="none", color="none")+ theme_bw() + theme(axis.text.y=element_blank()) readme_reading_time_plot #plotting readme reading time readme_reading_time_plot <- ggplot(readme_df, aes(x=reading_time, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-10, 140) + guides(fill="none", color="none")+ theme_bw() + theme(axis.title.y=element_blank()) readme_reading_time_plot #plotting readme reading time readme_reading_time_plot <- ggplot(readme_df, aes(x=reading_time, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-10, 140) + guides(fill="none", color="none")+ theme_bw() #theme(axis.title.y=element_blank()) readme_reading_time_plot #plotting readme reading time readme_reading_time_plot <- ggplot(readme_df, aes(x=reading_time, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-10, 140) + guides(fill="none", color="none")+ theme_bw() grid.arrange(contributing_reading_ease, contributing_reading_time_plot,readme_reading_ease, readme_reading_time_plot, nrow = 2) #plotting readme reading time readme_reading_time_plot <- ggplot(readme_df, aes(x=reading_time, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-10, 90) + guides(fill="none", color="none")+ theme_bw() grid.arrange(contributing_reading_ease, contributing_reading_time_plot,readme_reading_ease, readme_reading_time_plot, nrow = 2) grid.arrange(contributing_reading_ease, contributing_reading_time_plot,readme_reading_ease, readme_reading_time_plot, nrow = 2, labels = c("a)","b)")) grid.arrange(contributing_reading_ease, contributing_reading_time_plot,readme_reading_ease, readme_reading_time_plot, nrow = 2) library(ggpubr) ggarrange(contributing_reading_ease, contributing_reading_time_plot,readme_reading_ease, readme_reading_time_plot, nrow = 2,labels = c("a)","b)") ) ggarrange(contributing_reading_ease, contributing_reading_time_plot,readme_reading_ease, readme_reading_time_plot, ncol = 2, nrow = 2,labels = c("a)","b)") ) grid.arrange(contributing_reading_ease, contributing_reading_time_plot,readme_reading_ease, readme_reading_time_plot, nrow = 2) # plotting contributing reading time contributing_reading_time_plot <- ggplot(contributing_df, aes(x=reading_time, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 90) + ylab("readme density") + guides(fill="none", color="none")+ theme_bw() # plotting contributing reading ease contributing_reading_ease <- ggplot(contributing_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + ylab("readme density") + xlim(-10, 90) + theme_bw() + theme(legend.position = "top") #plotting readme reading ease readme_reading_ease <- ggplot(readme_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-10, 90) + ylab("readme density") + guides(fill="none", color="none")+ theme_bw() #plotting readme reading time readme_reading_time_plot <- ggplot(readme_df, aes(x=reading_time, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-10, 90) + ylab("readme density") + guides(fill="none", color="none")+ theme_bw() # plotting contributing reading time contributing_reading_time_plot <- ggplot(contributing_df, aes(x=reading_time, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 90) + ylab("contributing density") + guides(fill="none", color="none")+ theme_bw() # plotting contributing reading ease contributing_reading_ease <- ggplot(contributing_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + ylab("contributing density") + xlim(-10, 90) + theme_bw() + theme(legend.position = "top") contributing_reading_ease grid.arrange(contributing_reading_ease, contributing_reading_time_plot,readme_reading_ease, readme_reading_time_plot, nrow = 2) library(tidyverse) library(plyr) library(gridExtra) library(ggpubr) # script for the analysis of document readability metrics # readability metrics will be studied controlled by their length # gaughan@u.northwestern.edu # loading in the data try(setwd(dirname(rstudioapi::getActiveDocumentContext()$path))) readme_df <- read_csv("../text_analysis/draft_readability_readme.csv") contributing_df <- read_csv("../text_analysis/draft_readability_contributing.csv") #getting basic stats for the readme readability median(readme_df$flesch_reading_ease) median(readme_df$linsear_write_formula) median(contributing_df$reading_time) median(contributing_df$linsear_write_formula) #plotting readme reading ease readme_reading_ease <- ggplot(readme_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-10, 90) + ylab("readme density") + guides(fill="none", color="none")+ theme_bw() readme_reading_ease #plotting readme reading time readme_reading_time_plot <- ggplot(readme_df, aes(x=reading_time, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-10, 90) + ylab("readme density") + guides(fill="none", color="none")+ theme_bw() # establishing the color scheme subdirColors <- setNames( c('firebrick1', 'forestgreen', 'cornflowerblue') , levels(contributing_df$subdir) ) #plotting readme reading ease readme_reading_ease <- ggplot(readme_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-10, 90) + ylab("readme density") + guides(fill="none", color="none")+ theme_bw() #plotting readme reading time readme_reading_time_plot <- ggplot(readme_df, aes(x=reading_time, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-10, 90) + ylab("readme density") + guides(fill="none", color="none")+ theme_bw() # plotting contributing reading time contributing_reading_time_plot <- ggplot(contributing_df, aes(x=reading_time, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 90) + ylab("contributing density") + guides(fill="none", color="none")+ theme_bw() # plotting contributing reading ease contributing_reading_ease <- ggplot(contributing_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + ylab("contributing density") + xlim(-10, 90) + theme_bw() + theme(legend.position = "top") contributing_reading_ease grid.arrange(contributing_reading_ease, contributing_reading_time_plot,readme_reading_ease, readme_reading_time_plot, nrow = 2) # plotting contributing linsear writing formula contributing_linsear_plot <- ggplot(contributing_df, aes(x=linsear_write_formula, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-30, 30) + guides(fill="none", color="none")+ theme_bw() # plotting contributing reading time contributing_reading_time_plot <- ggplot(contributing_df, aes(x=reading_time, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 90) + ylab("contributing density") + guides(fill="none", color="none")+ theme_bw() # plotting contributing mcalpine eflaw contributing_mcalpine_eflaw <- ggplot(contributing_df, aes(x=mcalpine_eflaw, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 70) + guides(fill="none", color="none")+ theme_bw() grid.arrange(contributing_reading_ease, contributing_reading_time_plot,contributing_linsear_plot, contributing_mcalpine_eflaw readme_reading_ease, readme_reading_time_plot, nrow = 2) grid.arrange(contributing_reading_ease, contributing_reading_time_plot,contributing_linsear_plot, contributing_mcalpine_eflaw, readme_reading_ease, readme_reading_time_plot, nrow = 2) readme_linsear_plot <- ggplot(readme_df, aes(x=linsear_write_formula, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-10, 30) + ylab("readme density") + guides(fill="none", color="none")+ theme_bw() # plotting contributing linsear writing formula contributing_linsear_plot <- ggplot(contributing_df, aes(x=linsear_write_formula, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 30) + guides(fill="none", color="none")+ theme_bw() readme_mcalpine_eflaw <- ggplot(readme_df, aes(x=mcalpine_eflaw, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 60) + guides(fill="none", color="none")+ theme_bw() grid.arrange(contributing_reading_ease, contributing_reading_time_plot,contributing_linsear_plot, contributing_mcalpine_eflaw, readme_reading_ease, readme_reading_time_plot, readme_linsear_plot, readme_mcalpine_eflaw, nrow = 2) # plotting contributing mcalpine eflaw contributing_mcalpine_eflaw <- ggplot(contributing_df, aes(x=mcalpine_eflaw, group=as.factor(subdir))) + scale_color_manual(values = subdirColors) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-10, 60) + guides(fill="none", color="none")+ theme_bw() #plotting readme reading ease readme_reading_ease <- ggplot(readme_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-5, 90) + ylab("readme density") + guides(fill="none", color="none")+ theme_bw() #plotting readme reading time readme_reading_time_plot <- ggplot(readme_df, aes(x=reading_time, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-5, 90) + ylab("readme density") + guides(fill="none", color="none")+ theme_bw() readme_linsear_plot <- ggplot(readme_df, aes(x=linsear_write_formula, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + xlim(-5, 30) + ylab("readme density") + guides(fill="none", color="none")+ theme_bw() readme_mcalpine_eflaw <- ggplot(readme_df, aes(x=mcalpine_eflaw, group=as.factor(subdir))) + scale_color_manual(values = subdirColors) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-5, 60) + guides(fill="none", color="none")+ theme_bw() # plotting contributing linsear writing formula contributing_linsear_plot <- ggplot(contributing_df, aes(x=linsear_write_formula, group=as.factor(subdir))) + scale_color_manual(values = subdirColors) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-5, 30) + guides(fill="none", color="none")+ theme_bw() # plotting contributing reading time contributing_reading_time_plot <- ggplot(contributing_df, aes(x=reading_time, group=as.factor(subdir))) + scale_color_manual(values = subdirColors) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-5, 90) + ylab("contributing density") + guides(fill="none", color="none")+ theme_bw() # plotting contributing mcalpine eflaw contributing_mcalpine_eflaw <- ggplot(contributing_df, aes(x=mcalpine_eflaw, group=as.factor(subdir))) + scale_color_manual(values = subdirColors) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + xlim(-5, 60) + guides(fill="none", color="none")+ theme_bw() # plotting contributing reading ease contributing_reading_ease <- ggplot(contributing_df, aes(x=flesch_reading_ease, group=as.factor(subdir))) + geom_density(aes(color = as.factor(subdir), fill=as.factor(subdir)), alpha=0.2, position="identity") + scale_color_manual(values = subdirColors) + ylab("contributing density") + xlim(-5, 90) + theme_bw() + theme(legend.position = "top") grid.arrange(contributing_reading_ease, contributing_reading_time_plot,contributing_linsear_plot, contributing_mcalpine_eflaw, readme_reading_ease, readme_reading_time_plot, readme_linsear_plot, readme_mcalpine_eflaw, nrow = 2) library(tidyverse) library(plyr) library(stringr) try(setwd(dirname(rstudioapi::getActiveDocumentContext()$path))) #load in data contrib_df <- read_csv("../final_data/deb_contrib_pop_change.csv") View(contrib_df) 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,])) } #some expansion needs to happens for each project expand_timeseries <- function(project_row) { longer <- project_row |> pivot_longer(cols = ends_with("new"), names_to = "window", values_to = "count") |> unnest(count) |> mutate(after_doc = as.numeric(str_detect(window, "after"))) |> mutate(is_collab = as.numeric(str_detect(window, "collab"))) return(longer) } expanded_contrib_data <- expand_timeseries(contrib_df[1,]) View(expanded_contrib_data)