This vignette is a description of the distribution characteristics of patients' Age bands for the CLAHRC NWL Heart Failure Care Bundle project at North West London Hospitals.

The original raw data set from North West London Hospitals clahrcnwlf::admission_data was extracted and cleaned for analysis by Dr. T Woodcock using clahrcnwlhf::clean_and_save. The data covers discharge periods 1st January 2012 to 31st October 2016.

Data set

This analysis is restricted to only emergency admissions data clahrcnwlhf::emergency_adms (i.e. data for those episodes for which admission_data_clean$AdmissionType = "Emergency").

Notes needed here

emergency_adms <- clahrcnwlhf::emergency_adms

AGE DISTRIBUTION FREQUENCY

Let us first restrict attention to only the first episode of each spell.

emergency_spells <- emergency_adms[
  which(emergency_adms[,"EpisodeNumber"] == 1),]

Age band distribution (split by) period.date

First lets plot a plot of age-dist Age Band frequency using emergency_spells data. Age Band in the first ggplot is split by period.date: period A (discharges before the CLAHRC NWL Heart Failure Care Bundle project) and period B (discharges after the CLAHRC NWL Heart Failure Care Bundle project)

#test <- clahrcnwlhf::plot_age_dist(emergency_adms)
#dataframe restricted to only rows where 'new.spell' = TRUE
ggplot2::ggplot(emergency_adms, ggplot2::aes(x=AgeBand))+ggplot2::geom_bar(width= 0.7)+ggplot2::facet_wrap( ~ period.date)+ggplot2::ggtitle("Distribution by Age Band Across Period Dates A and B")+ggplot2::coord_flip()+ggplot2::ylab("Frequency")+ggplot2::xlab("Age Band")

Age band distribution (Overall distribution, i.e period.date A & B combined)

Second lets plot out

ggplot2::ggplot(emergency_adms, ggplot2::aes(x=AgeBand))+ggplot2::geom_bar(width= 0.7)+ggplot2::ggtitle("Distribution by Age Bands")+ggplot2::coord_flip()+ggplot2::ylab("Frequency")+ggplot2::xlab("Age Band")

Frequency table

ageband_perioddate <- clahrcnwlhf::plot_dist_table(emergency_adms)
#age band distribution for both periods + sum of both
addmargins(table(emergency_adms$AgeBand, emergency_adms$period.date),2)
ageband_perioddate #this is what I run in the command line

The html_vignette template includes a basic CSS theme. To override this theme you can specify your own CSS in the document metadata as follows:

output: 
  rmarkdown::html_vignette:
    css: mystyles.css

Figures

The figure sizes have been customised so that you can easily put two images side-by-side.

plot(1:10)
plot(10:1)

You can enable figure captions by fig_caption: yes in YAML:

output:
  rmarkdown::html_vignette:
    fig_caption: yes

Then you can use the chunk option fig.cap = "Your figure caption." in knitr.

More Examples

You can write math expressions, e.g. $Y = X\beta + \epsilon$, footnotes^[A footnote here.], and tables, e.g. using knitr::kable().

knitr::kable(head(mtcars, 10))

Also a quote using >:

"He who gives up [code] safety for [code] speed deserves neither." (via)



HorridTom/clahrcnwlhf documentation built on May 7, 2019, 4:02 a.m.