knitr::opts_chunk$set(echo = FALSE, size = "small", warning = FALSE, message = FALSE, cache = FALSE, fig.pos="H") library(tidyverse) library(tidymodels) library(patchwork) library(ggrepel)
tictoc::tic("compare_versions") output_function <- compare_versions_read_outside( dir_old <- "C:/doutorado/joda-time/joda-time-2.9", dir_new <- "C:/doutorado/joda-time/joda-time-2.10", log = "jodatime-2_9-2_10" ) tictoc::toc() tictoc::tic("compare_versions") output_function <- compare_versions_read_outside( dir_old <- "C:/doutorado/joda-time/joda-time-2.8", dir_new <- "C:/doutorado/joda-time/joda-time-2.9", log = "jodatime-2_8-2_9" ) tictoc::toc() tictoc::tic("compare_versions") output_function <- compare_versions_read_outside( dir_old <- "C:/doutorado/joda-time/joda-time-2.7", dir_new <- "C:/doutorado/joda-time/joda-time-2.8", log = "jodatime-2_7-2_8" ) tictoc::toc() tictoc::tic("compare_versions") output_function <- compare_versions_read_outside( dir_old <- "C:/doutorado/joda-time/joda-time-2.6", dir_new <- "C:/doutorado/joda-time/joda-time-2.7", log = "jodatime-2_6-2_7" ) tictoc::toc() tictoc::tic("compare_versions") output_function <- compare_versions_read_outside( dir_old <- "C:/doutorado/joda-time/joda-time-2.5", dir_new <- "C:/doutorado/joda-time/joda-time-2.6", log = "jodatime-2_5-2_6" ) tictoc::toc() tictoc::tic("compare_versions") output_function <- compare_versions_read_outside( dir_old <- "C:/doutorado/joda-time/joda-time-2.4", dir_new <- "C:/doutorado/joda-time/joda-time-2.5", log = "jodatime-2_4-2_5" ) tictoc::toc() tictoc::tic("compare_versions") output_function <- compare_versions_read_outside( dir_old <- "C:/doutorado/joda-time/joda-time-2.3", dir_new <- "C:/doutorado/joda-time/joda-time-2.4", log = "jodatime-2_3-2_4" ) tictoc::toc() tictoc::tic("compare_versions") output_function <- compare_versions_read_outside( dir_old <- "C:/doutorado/joda-time/joda-time-2.2", dir_new <- "C:/doutorado/joda-time/joda-time-2.3", log = "jodatime-2_2-2_3" ) tictoc::toc() tictoc::tic("compare_versions") output_function <- compare_versions_read_outside( dir_old <- "C:/doutorado/joda-time/joda-time-2.1", dir_new <- "C:/doutorado/joda-time/joda-time-2.2", log = "jodatime-2_1-2_2" ) tictoc::toc() tictoc::tic("compare_versions") output_function <- compare_versions_read_outside( dir_old <- "C:/doutorado/joda-time/joda-time-2.0", dir_new <- "C:/doutorado/joda-time/joda-time-2.1", log = "jodatime-2_0-2_1" ) tictoc::toc() tictoc::tic("compare_versions") output_function <- compare_versions_read_outside( dir_old <- "C:/doutorado/joda-time/joda-time-1.6", dir_new <- "C:/doutorado/joda-time/joda-time-2.0", log = "jodatime-1_6-2_0" ) tictoc::toc() tictoc::tic("compare_versions") output_function <- compare_versions_read_outside( dir_old <- "C:/doutorado/joda-time/joda-time-1.5", dir_new <- "C:/doutorado/joda-time/joda-time-1.6", log = "jodatime-1_5-1_6" ) tictoc::toc() tictoc::tic("compare_versions") output_function <- compare_versions_read_outside( dir_old <- "C:/doutorado/joda-time/joda-time-1.4", dir_new <- "C:/doutorado/joda-time/joda-time-1.5", log = "jodatime-1_4-1_5" ) tictoc::toc() tictoc::tic("compare_versions") output_function <- compare_versions_read_outside( dir_old <- "C:/doutorado/joda-time/joda-time-1.3", dir_new <- "C:/doutorado/joda-time/joda-time-1.4", log = "jodatime-1_3-1_4" ) tictoc::toc() tictoc::tic("compare_versions") output_function <- compare_versions_read_outside( dir_old <- "C:/doutorado/joda-time/joda-time-1.2", dir_new <- "C:/doutorado/joda-time/joda-time-1.3", log = "jodatime-1_2-1_3" ) tictoc::toc() extract_comments_from_directory( dir = "C:/doutorado/joda-time/joda-time-2.9", dest_file = "comments_jodatime_2_9.rds" ) extract_comments_from_directory( dir = "C:/doutorado/joda-time/joda-time-2.8", dest_file = "comments_jodatime_2_8.rds" ) extract_comments_from_directory( dir = "C:/doutorado/joda-time/joda-time-2.7", dest_file = "comments_jodatime_2_7.rds" ) extract_comments_from_directory( dir = "C:/doutorado/joda-time/joda-time-2.6", dest_file = "comments_jodatime_2_6.rds" ) extract_comments_from_directory( dir = "C:/doutorado/joda-time/joda-time-2.5", dest_file = "comments_jodatime_2_5.rds" ) extract_comments_from_directory( dir = "C:/doutorado/joda-time/joda-time-2.4", dest_file = "comments_jodatime_2_4.rds" ) extract_comments_from_directory( dir = "C:/doutorado/joda-time/joda-time-2.3", dest_file = "comments_jodatime_2_3.rds" ) extract_comments_from_directory( dir = "C:/doutorado/joda-time/joda-time-2.2", dest_file = "comments_jodatime_2_2.rds" ) extract_comments_from_directory( dir = "C:/doutorado/joda-time/joda-time-2.1", dest_file = "comments_jodatime_2_1.rds" ) extract_comments_from_directory( dir = "C:/doutorado/joda-time/joda-time-2.0", dest_file = "comments_jodatime_2_0.rds" ) extract_comments_from_directory( dir = "C:/doutorado/joda-time/joda-time-1.6", dest_file = "comments_jodatime_1_6.rds" ) extract_comments_from_directory( dir = "C:/doutorado/joda-time/joda-time-1.5", dest_file = "comments_jodatime_1_5.rds" ) extract_comments_from_directory( dir = "C:/doutorado/joda-time/joda-time-1.4", dest_file = "comments_jodatime_1_4.rds" ) extract_comments_from_directory( dir = "C:/doutorado/joda-time/joda-time-1.3", dest_file = "comments_jodatime_1_3.rds" ) extract_comments_from_directory( dir = "C:/doutorado/joda-time/joda-time-1.2", dest_file = "comments_jodatime_1_2.rds" ) extract_comments_from_directory( dir = "C:/doutorado/joda-time/joda-time-1.1", dest_file = "comments_jodatime_1_1.rds" ) extract_comments_from_directory( dir = "C:/doutorado/joda-time/joda-time-1.0", dest_file = "comments_jodatime_1.0.rds" ) extract_comments_from_directory( dir = "C:/doutorado/joda-time/joda-time-0.9", dest_file = "comments_jodatime_0_9.rds" )
kludgenudger::save_alerts( dir = here::here("joda-time"), pattern_versions = "^joda-time-", dest_dir = "alerts_jodatime", remove_str = "joda-time-", string_to_replace = "\\.", string_to_replace_with = "_" )
# rename_file_diff(pattern_diff = "C:/doutorado/joda-time", prefix = "joda-time" ) complement <- tribble( ~major_new, ~minor_new , 0, 9, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 2, 6, 2, 7, 2, 8, 2, 9, 2, 10 ) %>% mutate( major_old = lag(major_new), minor_old = lag(minor_new) ) %>% filter( !is.na(major_old) ) %>% mutate( file = str_glue("jodatime-{major_old}_{minor_old}-{major_new}_{minor_new}.rds"), root_new = str_glue("C:/doutorado/joda-time/joda-time-{major_new}.{minor_new}/"), root_old = str_glue("C:/doutorado/joda-time/joda-time-{major_old}.{minor_old}/") ) %>% select( file, root_new, root_old ) generate_diffs_from_versions( complement = complement, prefix = "jodatime" ) extract_selected_comments( path_to_comments = "comments_joda", output = "joda_selected_comments.rds" ) generate_ast_only_classes( dir = "C:/doutorado/joda-time/", pattern = "joda-time-.*", output_path = "only_classes_jodatime", pattern_major_minor_versions = "joda\\-time\\-(.*)\\.(.*)" ) results_comments <- create_version_comparisons_comment( pattern_diff = "jodatime", selected_comments_file = "joda_selected_comments.rds", dir_only_classes = "only_classes_jodatime", pattern_major_minor_versions_only_classes = "([0-9]*)_([0-9]*)" )
#jodatime results_alert <- kludgenudger::analyse_alerts_and_categories( package_start_outside_read = "\\.*", dir_read_all_alerts = here::here("tests/testthat/alerts_jodatime"), package_start_read_all_alerts = "\\.*", pattern_major_read_all_alerts = "^([0-9]*)[\\._]", pattern_minor_read_all_alerts = "^[0-9]*_([0-9]*)", prefix = "jodatime" ) results_comments <- kludgenudger::create_version_comparisons_comment( pattern_diff = "jodatime", selected_comments_file = "joda_selected_comments.rds", dir_only_classes = "only_classes_jodatime", pattern_major_minor_versions_only_classes = "([0-9]*)_([0-9]*)" )
alerts <- results_alert %>% rename_with( ~str_glue("{.x}_alerts") ) comments <- results_comments %>% rename_with( ~str_glue("{.x}_comments") ) comparison <- alerts %>% inner_join( comments, by = c( "major_version_old_alerts" = "major_version_old_comments" , "minor_version_old_alerts" = "minor_version_old_comments" , "major_version_new_alerts" = "major_version_new_comments" , "minor_version_new_alerts" = "minor_version_new_comments" ) ) %>% mutate( ratio_alerts = new_alerts/(new_alerts + fixed_alerts), ratio_comments = new_comments/(new_comments + fixed_comments), version = str_glue("{major_version_alerts}.{minor_version_alerts}") ) %>% rename_with( .cols = matches("_version_"), .fn = ~str_remove(.x, pattern = "_alerts") )
comparison_prepared <- comparison %>% mutate( across( .cols = matches("_version_"), .fns = ~if_else(.x == 0, NA_character_, as.character(.x) ), .names = "{.col}_str" ) ) %>% unite( col = version_old_str, major_version_old_str, minor_version_old_str, sep = "." ) %>% unite( col = version_new_str, major_version_new_str, minor_version_new_str, sep = "." ) %>% mutate( across( .cols = matches("version_(?:new|old)_str"), .fns = ~str_remove(.x, ".NA") ) ) %>% unite( col = "versions_transition", sep = " to ", version_old_str, version_new_str ) %>% mutate( versions_transition = fct_reorder( .f = versions_transition, .x = major_version_new * 1000 + minor_version_new ) ) comparison_prepared_clean <- comparison_prepared %>% filter( !is.nan(ratio_alerts) & !is.nan(ratio_comments) ) comparison_fixed_new_alerts <- comparison_prepared %>% select( fixed_alerts, new_alerts, versions_transition ) %>% pivot_longer( cols = ends_with("_alerts"), names_to = c("metric", ".value"), names_pattern = "(.*)_(.*)", names_transform = list(metric = str_to_title) ) ggplot_fixed_new <- ggplot( data = comparison_fixed_new_alerts, aes( x = versions_transition, y = alerts, color = metric, group = metric ) ) + geom_line( size = 1.2 ) + geom_point( size = 2.5 ) + theme_minimal() + scale_color_manual( values = c(Fixed = "darkgreen", New = "darkred") ) + theme( axis.text.x = element_text(angle = 90) , legend.position = "top" ) + scale_y_continuous( labels = number_format(big.mark = ","), limits = c(0,NA) ) + ggtitle( "Number of fixed/new alerts per version transition" ) + labs( x = "Transition", y = "Number of alerts", color = "Category" ) comparison_fixed_new_comments <- comparison_prepared %>% select( fixed_comments, new_comments, versions_transition ) %>% pivot_longer( cols = ends_with("_comments"), names_to = c("metric", ".value"), names_pattern = "(.*)_(.*)", names_transform = list(metric = str_to_title) ) ggplot_fixed_new_comments <- ggplot(comparison_fixed_new_comments, aes( x = versions_transition, y = comments, color = metric, group = metric ) ) + geom_line( size = 1.2 ) + geom_point( size = 2.5 ) + theme_minimal() + scale_color_manual( values = c(Fixed = "darkgreen", New = "darkred") ) + theme( axis.text.x = element_text(angle = 90) , legend.position = "top" ) + scale_y_continuous( labels = number_format(big.mark = ","), limits = c(0,NA) ) + ggtitle( "Number of fixed/new comments per version transition" ) + labs( x = "Transition", y = "Number of comments", color = "Category" ) ggplot_total_alerts <- ggplot(comparison_prepared, aes( x = versions_transition, y = n_alerts, ) ) + geom_line( size = 1.2, color = "darkblue", group = 1, aes( x = versions_transition, y = n_alerts ) ) + geom_point( size = 2.5, color = "darkblue" ) + theme_minimal() + theme( axis.text.x = element_text(angle = 90) , legend.position = "top" ) + scale_y_continuous( labels = number_format(big.mark = ","), limits = c(0,NA) ) + ggtitle( "Number of total alerts after version transition" ) + labs( x = "Transition", y = "Number of alerts" ) ggplot_total_comments <- ggplot(comparison_prepared, aes( x = versions_transition, y = n_comments, ) ) + geom_line( size = 1.2, color = "darkblue", group = 1, aes( x = versions_transition, y = n_comments ) ) + geom_point( size = 2.5, color = "darkblue" ) + theme_minimal() + theme( axis.text.x = element_text(angle = 90) , legend.position = "top" ) + scale_y_continuous( labels = number_format(big.mark = ","), limits = c(0,NA) ) + ggtitle( "Number of total comments after version transition" ) + labs( x = "Transition", y = "Number of comments" ) ggplot_total_alerts / ggplot_fixed_new / ggplot_total_comments / ggplot_fixed_new_comments + plot_layout(heights = unit(c(3, 3, 3, 3), c("cm", "cm", "cm", "cm") ), widths = unit(c(15, 15, 15, 15), c("cm", "cm", "cm", "cm") ))
correl_prop <- cor( comparison_prepared_clean$ratio_alerts, comparison_prepared_clean$ratio_comments )
ggplot( comparison_prepared_clean, aes( y = ratio_comments , x = ratio_alerts, ) ) + geom_point() + geom_text_repel(aes(label = versions_transition), nudge_y = 0.05, size = 2) + geom_smooth(method = "lm") + ggtitle( "Proportion of new comments x Proportion of new alerts" ) + labs( y = "Proportion of new alerts", x = "Proportion of new comments", size = "Change" ) + scale_x_continuous( label = percent_format(), limits = c(0, 1) ) + scale_y_continuous( label = percent_format(), limits = c(0, 1) ) + scale_size_continuous( label = number_format(big.mark = ",", accuracy = 1) ) + theme_minimal() + theme( legend.position = "top" ) + NULL
library(parsnip) library(gtsummary) lm_prop <- linear_reg() %>% set_engine("lm") lm_prop_fit <- lm_prop %>% fit(ratio_comments ~ ratio_alerts, data = comparison_prepared_clean)
tbl_prop <- tbl_regression( lm_prop_fit$fit, pvalue_fun = function(x) style_pvalue(x, digits = 2), label = ratio_alerts ~ "New Alerts Proportion", intercept = TRUE, ) tbl_prop %>% as_kable_extra(caption = "\\label{tab_reg} Regression: comments on alerts")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.