From e0faa24f40efcc7df69a4e2508cfe6b83d9f6f49 Mon Sep 17 00:00:00 2001 From: Jens Sauer Date: Thu, 19 Nov 2020 13:20:52 +0100 Subject: [PATCH] Add basic histograms This adds some basic histograms to show the distribution of age at transplatation and year of transplatation. --- plots.R | 2 ++ visualize.R | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 visualize.R diff --git a/plots.R b/plots.R index adf8398..7940691 100644 --- a/plots.R +++ b/plots.R @@ -5,8 +5,10 @@ source("survival.R") source("secmal.R") +source("visualize.R") # # Make all plots and save to file sma_plot_file_surv() sma_plot_file_secmal() +sma_plot_file_hist() diff --git a/visualize.R b/visualize.R new file mode 100644 index 0000000..422bdce --- /dev/null +++ b/visualize.R @@ -0,0 +1,22 @@ +# Visualize basics from data +# +# License: GPL version 3 +# Jens Mathis Sauer (c) 2020 + +source("utils.R") +sma_init() + +sma_hist_asct_age <- function() { + data <- data.frame(asct_age = secmal$asct_age) + ggplot(data, aes(x = asct_age)) + geom_histogram(binwidth = 5) +} + +sma_hist_asct_year <- function() { + data <- data.frame(asct_year = secmal$asct_year) + ggplot(data, aes(x = asct_year)) + geom_histogram(binwidth = 1) +} + +sma_plot_file_hist <- function() { + sma_plot_file("hist_asct_age.png", png, sma_hist_asct_age) + sma_plot_file("hist_asct_year.png", png, sma_hist_asct_year) +}