-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f151d5
commit b1f651a
Showing
52 changed files
with
12,874 additions
and
4 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
00-1-age-and-year-of-deathofharold-shipmans-victims/00-1-age-year-shipman victims-x.Rmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
title: "Art of Statistics: 0-1 Age and Year of Shipman Victims" | ||
#output: md_document | ||
output: html_document | ||
--- | ||
|
||
*************************************************************************** | ||
|
||
Data are contained in [00-1-shipman-confirmed-victims-x.csv](00-1-shipman-confirmed-victims-x.csv), and taken from [Chronological List of Decided Cases in the Shipman Inquiry](https://webarchive.nationalarchives.gov.uk/20090808221518/http://www.the-shipman-inquiry.org.uk/fr_casesbyyear.asp?year=74&from=r). | ||
|
||
```{r 0-1 Scatter and bars, fig.height=6, fig.width=6, fig.align='left'} | ||
library(magrittr) | ||
library(ggplot2) | ||
library(ggpubr) | ||
library(ggExtra) | ||
# read data to dataframe | ||
df<-read.csv("00-1-shipman-confirmed-victims-x.csv",header=TRUE) | ||
# scatter-plot | ||
s <- ggplot(df, aes(x=fractionalDeathYear, y=Age, colour=reorder(gender2,gender))) # initialise plot for the scatter-chart | ||
s <- s + geom_point(size=1) # assign scatter chart-type with size 1 points | ||
s <- s + labs(x ="Year", y="Age of victim") # Adds axis labels | ||
s <- s + scale_x_continuous(breaks=seq(1975, 1995, 5), limits = c(1974,1998)) #x-axis labels every 5 years and between 74 and 98 | ||
s <- s + scale_y_continuous(breaks=seq(40, 90, 10), limits = c(39,95)) # y-axis every 10 years and between 39 and 95 | ||
#s <- s + scale_size_continuous(name = "Size", guide = FALSE) # turns off size legend | ||
s <- s + theme(legend.position=c(0.125,1.12 ), legend.background = element_rect(colour = "black"), legend.title = element_blank()) # positions. borders, and un-titles the legend | ||
# with marginal histogram | ||
ggMarginal(s, type="histogram") | ||
``` | ||
|
||
Figure 0.1 A scatter-plot showing the age and the year of death of Harold Shipman's 215 confirmed victims. Bar-charts have been added on the axes to reveal the pattern of ages and the pattern of years in which he committed murders. | ||
|
429 changes: 429 additions & 0 deletions
429
00-1-age-and-year-of-deathofharold-shipmans-victims/00-1-age-year-shipman_victims-x.html
Large diffs are not rendered by default.
Oops, something went wrong.
216 changes: 216 additions & 0 deletions
216
00-1-age-and-year-of-deathofharold-shipmans-victims/00-1-shipman-confirmed-victims-x.csv
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
01-1-2-3-child-heart-survival-times/01-1-child-heart-survival-x.Rmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
title: "Art of Statistics: Figure 1.1 (page 26)" | ||
#output: md_document | ||
output: html_document | ||
--- | ||
### Figure 1.1: Survival rates following child heart surgery in thirteen hospitals from 2012-2015 | ||
|
||
Data are shown in Table 1.1 (page 23) and are contained in [01-1-child-heart-survival-x.csv](01-1-child-heart-survival-x.csv). The data were originally presented in the [NCHDA 2012-15 report](https://nicor4.nicor.org.uk/chd/an_paeds.nsf/vwContent/Analysis%20Documents?Opendocument), but are best seen on [childrensheartsurgery.info](http://childrensheartsurgery.info/). | ||
|
||
```{r figure 1-1} | ||
library(ggplot2) | ||
ThirtyDaySurv <-read.csv("01-1-child-heart-survival-x.csv", header=TRUE) # reads data into ThirtyDaySurv data frame | ||
nhosp=length(ThirtyDaySurv$Hospital) | ||
p <- ggplot(ThirtyDaySurv, aes(x=reorder(Hospital,nhosp:1), y= ThirtyDaySurvival, fill=Hospital)) # constructs initial plot object, , starting with top row | ||
p <- p + geom_bar(stat = "identity") # assigns bar chart-type | ||
p <- p + coord_flip(ylim = c(86,100)) # flips to horizontal bars and limits y-axis | ||
p <- p + scale_y_continuous(breaks=seq(86, 100, 2)) # assigns breaks every 2 percent | ||
p <- p + scale_colour_brewer(palette = "Accent") # sets the colour palette | ||
p <- p + theme(legend.position="none") # removes the legend | ||
p <- p + labs(x="", y="% surviving 30 days") # Adds y-axis label | ||
p # draws the plot | ||
``` | ||
|
||
_Figure 1.1 Bar-chart of 30-day survival rates for thirteen hospitals. The choice of the start of the horizontal axis, here 86%, can have a crucial effect on the impression given by the graphic. If the axis starts at 0%, all the hospitals will look indistinguishable, whereas if we started at 95% the differences would look misleadingly dramatic._ | ||
|
||
For other ways of displaying and explaining this data, and more recent results, see [childrensheartsurgery.info](http://childrensheartsurgery.info/). |
14 changes: 14 additions & 0 deletions
14
01-1-2-3-child-heart-survival-times/01-1-child-heart-survival-x.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Hospital,Operations,Survivors,Deaths,ThirtyDaySurvival,PercentageDying | ||
London - Harley Street ,418,413,5,98.8,1.2 | ||
Leicester,607,593,14,97.7,2.3 | ||
Newcastle,668,653,15,97.8,2.2 | ||
Glasgow,760,733,27,96.3,3.7 | ||
Southampton,829,815,14,98.3,1.7 | ||
Bristol,835,821,14,98.3,1.7 | ||
Dublin,983,960,23,97.7,2.3 | ||
Leeds,1038,1016,22,97.9,2.1 | ||
London - Brompton,1094,1075,19,98.3,1.7 | ||
Liverpool,1132,1112,20,98.2,1.8 | ||
London - Evelina,1220,1185,35,97.1,2.9 | ||
Birmingham,1457,1421,36,97.5,2.5 | ||
London - Great Ormond Street,1892,1873,19,99,1 |
425 changes: 425 additions & 0 deletions
425
01-1-2-3-child-heart-survival-times/01-1-child-heart-survival-x.html
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
29 changes: 29 additions & 0 deletions
29
01-1-2-3-child-heart-survival-times/01-3-child-heart-proportions-x.Rmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
title: "Art of Statistics: Figure 1.3 (page 30)" | ||
#output: md_document | ||
output: html_document | ||
--- | ||
|
||
### Figure 1.3: Percentage of all child heart surgery being carried out in each of thirteen hospitals | ||
|
||
Data are shown in Table 1.1 (page 23) and are contained in [01-1-child-heart-survival-x.csv](01-1-child-heart-survival-x.csv). The data were originally presented in the [NCHDA 2012-15 report](https://nicor4.nicor.org.uk/chd/an_paeds.nsf/vwContent/Analysis%20Documents?Opendocument), but are best seen on [childrensheartsurgery.info](http://childrensheartsurgery.info/). | ||
|
||
|
||
```{r figure 1-3} | ||
library(ggplot2) | ||
df <- read.csv("01-1-child-heart-survival-x.csv", header=TRUE) # reads csv into dataframe, df | ||
df$Percentage = 100*df$Operations/sum(df$Operations) | ||
df$Pos= rank(df$Percentage) | ||
bp <- ggplot(df, aes(x=reorder(Hospital,-Pos), y=Percentage, fill=Hospital)) #sets initial plot object from the dataframe for Hospitals, reordered by Percentage (descending) as the y-values, colour-filled by Hospital | ||
bp <- bp + geom_bar(stat = "identity") + labs(x="Hospital") # makes the plot a bar-chart | ||
bp <- bp + coord_flip() # makes it an horizontal bar chart | ||
bp <- bp + scale_y_continuous(breaks=seq(2,16,2)) # breaks every two-count | ||
bp <- bp + theme(legend.position="none") # removes the legend | ||
bp <- bp + labs(y="Percentage of all operations in 2012-15 \nthat are carried out in each hospital", x="") # Adds labels | ||
bp # draws the plot | ||
``` | ||
|
||
_Figure 1.3 Percentage of all operations in 2012-15 that are carried out in each hospital: a clearer representation using a horizontal bar chart._ |
424 changes: 424 additions & 0 deletions
424
01-1-2-3-child-heart-survival-times/01-3-child-heart-proportions-x.html
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.