1
0
govdoc-cr-analysis/plots/text_presentation.R
2025-02-07 16:59:56 -08:00

82 lines
3.4 KiB
R

library(tidyverse)
readme_groupings <- read.csv('text_analysis/0207_readme_merged_manifest.csv')
contrib_groupings <- read.csv('text_analysis/0207_contributing_merged_manifest.csv')
contrib_groupings$filename <- contrib_groupings$fvf_filepath
readme_groupings$filename <- readme_groupings$fvf_filepath
readme_textstat <- read.csv('text_analysis/020725_README_readability.csv')
contributing_textstat <- read.csv('text_analysis/020725_CONTRIBUTING_readability.csv')
doctypeColors <-
setNames( c('#c7756a','#5da2d8')
, c("README","CONTRIBUTING"))
readme_textstat$type = "README"
contributing_textstat$type = "CONTRIBUTING"
all_df = rbind(contributing_textstat,readme_textstat)
all_df$type <- factor(all_df$type, levels = c("CONTRIBUTING", "README"))
length_plot_all <- ggplot(all_df, aes(x=word_count, group=as.factor(type))) +
geom_density(aes(fill = as.factor(type)), color = NA, alpha=0.6, position="identity")+
scale_fill_manual(values = doctypeColors) +
xlim(-10, 600) +
labs(
x = "Word Count",
y = "Density Across Documents",
fill="Document Type"
) +
theme_bw() +
theme(legend.position = "top")
length_plot_all
#ggsave(filename = "plots/cr-0207-wc-density.png", plot = length_plot_all, width = 9, height = 9, dpi = 800)
contributing_df <- inner_join(contributing_textstat, contrib_groupings, by=c("filename"="new_filepath"))
readme_df <- inner_join(readme_textstat, readme_groupings, by=c("filename"="new_filepath"))
subdirColors <-
setNames( c('#31449c', '#4a7c85', '#c5db68')
, c(0,1,2) )
contributing_reading_time_plot <- ggplot(contributing_df, aes(x=reading_time, group=as.factor(ranef_grouping))) +
scale_fill_manual(values = subdirColors, labels=c('CI < 0', '0 in CI', '0 < CI')) +
geom_density(aes(fill=as.factor(ranef_grouping)), position="fill") +
xlim(-5, 90) +
labs(x= NULL, y= NULL, fill="RE Grouping")+
theme_bw() +
theme(legend.position = "inside",
legend.position.inside = c(.89, .92),
legend.justification = c("right", "top"),
legend.direction = "horizontal",
legend.margin = margin(6, 6, 6, 6))
contributing_reading_time_plot
contributing_reading_ease <- ggplot(contributing_df, aes(x=flesch_reading_ease, group=as.factor(ranef_grouping))) +
geom_density(aes(fill=as.factor(ranef_grouping)), position="fill") +
scale_fill_manual(values = subdirColors, labels=c('CI < 0', '0 in CI', '0 < CI')) +
labs(x= NULL, y="CONTRIBUTING Density", fill="RE Grouping")+
xlim(-5, 90) +
theme_bw() +
guides(fill="none", color="none")
#contributing_reading_ease
readme_reading_time_plot <- ggplot(readme_df, aes(x=reading_time, group=as.factor(ranef_grouping))) +
geom_density(aes(fill=as.factor(ranef_grouping)), position="fill") +
scale_fill_manual(values = subdirColors) +
xlim(-5, 90) +
labs(x= "Reading Time (s)", y= NULL)+
guides(fill="none", color="none")+
theme_bw()
readme_reading_time_plot
readme_reading_ease <- ggplot(readme_df, aes(x=flesch_reading_ease, group=as.factor(ranef_grouping))) +
geom_density(aes(fill=as.factor(ranef_grouping)), position="fill") +
scale_fill_manual(values = subdirColors) +
xlim(-5, 90) +
labs(x= "Flesch Reading Ease", y= "README Density")+
guides(fill="none", color="none")+
theme_bw()
readme_reading_ease
library(gridExtra)
grid.arrange(contributing_reading_ease, contributing_reading_time_plot, readme_reading_ease, readme_reading_time_plot, nrow = 2)