#* days_plot_epoch_stats: #* attr: #* fillcolor: '2' #* desc: Summary visualization of pre vs post epoch lengths. #* ext: R #* inputs: #* - person_all_facts #* library(dplyr) library(ggplot2) library(tidyr) days_plot_epoch_stats <- function(person_all_facts) { epoch_stats_by_person <- SparkR::collect(SparkR::select(person_all_facts, c("pre_epoch_effective_days", "post_epoch_effective_days", "cohort"))) print(str(epoch_stats_by_person)) # p <- ggplot(epoch_stats_by_person) + # stat_summary_2d(aes(x = pre_num_condition_eras, y = post_num_condition_eras, z = increase_effective_days), fun = length, bins = 60) + # scale_x_continuous(trans = "log10") + # scale_y_continuous(trans = "log10") + # scale_fill_continuous(trans = "log10") + # annotation_logticks(sides = "bl") # plot(p) p2 <- ggplot(epoch_stats_by_person) + stat_summary_hex(aes(x = pre_epoch_effective_days, y = post_epoch_effective_days, z = cohort), fun = length, bins = 60) + scale_x_continuous(trans = "log10") + scale_y_continuous(trans = "log10") + #scale_fill_continuous(trans = "log10") + annotation_logticks(sides = "bl") + facet_wrap(~ cohort) + coord_equal() plot(p2) return(NULL) }