layout: true <div class="my-footer"><span>kathoffman.github.io/swimmer-plots/slides.html</span></div> --- name: xaringan-title class: right, middle background-image: url(img/blue-foaming-waves-north-beach-nazare-portugal.jpg) background-size: cover <h1 style="color: white;">Making swimmer plots for longitudinal data using {ggplot}</h1> <img src="img/rmed-hex.png" alt="Rmed-hex-sticker" width="180" /> <h3 style="color: white;"> Kat Hoffman | August 25, 2022</h3> --- class: middle, center <img src="img/climbing_comic.jpeg" width="350"/> ### Find me at: [
khstats.com](https://khstats.com) [
@kat\_hoffman\_](http://twitter.com/kat_hoffman_) [
@kathoffman](http://github.com/kathoffman) [
kathoffman.stats@gmail.com](mailto:kathoffman.stats@gmail.com) --- # Swimmer plot .pull-left[ - Graphical way to show a **subject's profile over time** - A series of horizontal lines, in which **each line represents one subject** - **Colors or shapes** on the line **indicate treatments** or other statuses of that subject at a particular time ] .pull-right[ <div class="figure" style="text-align: center"> <img src="img/cell_swimmer.png" alt="Image: Shen et al. Cell 182, 59–72, July 9, 2020" width="600" /> <p class="caption">Image: Shen et al. Cell 182, 59–72, July 9, 2020</p> </div> ] <!-- -- --> <!-- - --> <!-- -- --> <!-- - --> <!-- -- --> <!-- - Excellent for exploratory data analysis (EDA) of longitudinal data (e.g. visualize missigness or sampling patterns) --> <!-- -- --> <!-- - Can be included as a final product (e.g. manuscripts, presentations) to explain cohort composition, treatment variability, and more --> <!-- -- --> <!-- - While `R` packages such as `swimmer` exist, it is often faster and more customizable to write end-to-end `ggplot` code yourself --> --- # Do we *really* have to hand-code this? .pull-left[ - `R` packages such as `swimplot` do exist, but it is more customizable to write end-to-end `ggplot` code yourself - Configuring the legend correctly in `ggplot` can be tricky whether you use `swimplot` or not ] .pull-right[ <div class="figure"> <img src="img/swimmer_swimplot.png" alt="Image courtesy of {swimplot} vignette." width="500" /> <p class="caption">Image courtesy of {swimplot} vignette.</p> </div> ] --- .left-column[ ### Today's swimmer plot: We will show the timing of... - severe hypoxia - intubation - steroids administration - 28-day mortality ...in a cohort of hospitalized COVID-19 patients. ] .right-column[ <img src="img/swimmer.png" width="700" style="display: block; margin: auto;" /> ] --- # Step 1: Long-form data set .pull-left[ - ID column - Time column (e.g. day) - One column per status (e.g. drug A - yes/no, drug B - yes/no) - One row per subject per unit of time ] -- .pull-right[ ```r library(tidyverse) library(data.table) dat_long <- read_csv("https://raw.githubusercontent.com/kathoffman/steroids-trial-emulation/main/data/dat_trt_timeline.csv",col_types = list(id = "c", steroids = "c", death = "c", severe = "c")) dat_long |> data.table() ``` ``` id day intubation_status steroids death severe 1: 797 0 Not intubated 0 0 0 2: 797 1 Not intubated 0 0 0 3: 797 2 Not intubated 0 0 1 4: 797 3 Not intubated 0 0 0 5: 797 4 Not intubated 0 0 0 --- 415: 664 27 Not intubated 0 0 0 416: 664 28 Not intubated 0 0 0 417: 373 0 Not intubated 0 0 0 418: 373 1 Not intubated 0 0 0 419: 373 2 Not intubated 0 0 0 ``` ] --- # Step 2: Long-form data for plotting .pull-left[ - ID column (**optional: order by maximum time per subject**) - Time column - One column per status, **which is now the time if you want the status to be marked on the plot** - One row per subject per unit of time ] -- .pull-right[ This is a way to create data with a reordered patient ID (by hospital length-of-stay): ```r dat_reorder <- dat_long |> group_by(id) |> mutate(max_day = max(day)) |> ungroup() |> mutate(id = fct_reorder(factor(id), max_day)) ``` The next slide shows how to change the status columns to `{status}_this_day` columns. ] --- # Step 2: Long-form data for plotting ```r dat_swim <- dat_reorder |> mutate(severe_this_day = case_when(severe == 1 ~ day), steroids_this_day = case_when(steroids == 1 ~ day), death_this_day = case_when(death == 1 ~ day)) dat_swim |> paged_table() ``` <div data-pagedtable="false"> <script data-pagedtable-source type="application/json"> {"columns":[{"label":["id"],"name":[1],"type":["fct"],"align":["left"]},{"label":["day"],"name":[2],"type":["dbl"],"align":["right"]},{"label":["intubation_status"],"name":[3],"type":["chr"],"align":["left"]},{"label":["steroids"],"name":[4],"type":["chr"],"align":["left"]},{"label":["death"],"name":[5],"type":["chr"],"align":["left"]},{"label":["severe"],"name":[6],"type":["chr"],"align":["left"]},{"label":["max_day"],"name":[7],"type":["dbl"],"align":["right"]},{"label":["severe_this_day"],"name":[8],"type":["dbl"],"align":["right"]},{"label":["steroids_this_day"],"name":[9],"type":["dbl"],"align":["right"]},{"label":["death_this_day"],"name":[10],"type":["dbl"],"align":["right"]}],"data":[{"1":"797","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"797","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"797","2":"2","3":"Not intubated","4":"0","5":"0","6":"1","7":"16","8":"2","9":"NA","10":"NA"},{"1":"797","2":"3","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"797","2":"4","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"797","2":"5","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"797","2":"6","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"797","2":"7","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"797","2":"8","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"797","2":"9","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"797","2":"10","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"797","2":"11","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"797","2":"12","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"797","2":"13","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"797","2":"14","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"797","2":"15","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"797","2":"16","3":"Not intubated","4":"0","5":"1","6":"0","7":"16","8":"NA","9":"NA","10":"16"},{"1":"285","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"2","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"3","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"4","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"5","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"6","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"7","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"8","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"9","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"10","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"11","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"12","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"13","3":"Not intubated","4":"1","5":"0","6":"0","7":"28","8":"NA","9":"13","10":"NA"},{"1":"285","2":"14","3":"Not intubated","4":"1","5":"0","6":"0","7":"28","8":"NA","9":"14","10":"NA"},{"1":"285","2":"15","3":"Not intubated","4":"1","5":"0","6":"0","7":"28","8":"NA","9":"15","10":"NA"},{"1":"285","2":"16","3":"Not intubated","4":"1","5":"0","6":"0","7":"28","8":"NA","9":"16","10":"NA"},{"1":"285","2":"17","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"18","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"19","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"20","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"21","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"22","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"23","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"24","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"25","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"26","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"27","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"285","2":"28","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"1","3":"Not intubated","4":"0","5":"0","6":"1","7":"28","8":"1","9":"NA","10":"NA"},{"1":"555","2":"2","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"3","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"4","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"5","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"6","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"7","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"8","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"9","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"10","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"11","3":"Intubated","4":"1","5":"0","6":"0","7":"28","8":"NA","9":"11","10":"NA"},{"1":"555","2":"12","3":"Intubated","4":"1","5":"0","6":"0","7":"28","8":"NA","9":"12","10":"NA"},{"1":"555","2":"13","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"14","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"15","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"16","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"17","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"18","3":"Intubated","4":"1","5":"0","6":"0","7":"28","8":"NA","9":"18","10":"NA"},{"1":"555","2":"19","3":"Intubated","4":"1","5":"0","6":"0","7":"28","8":"NA","9":"19","10":"NA"},{"1":"555","2":"20","3":"Not intubated","4":"1","5":"0","6":"0","7":"28","8":"NA","9":"20","10":"NA"},{"1":"555","2":"21","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"22","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"23","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"24","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"25","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"26","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"27","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"555","2":"28","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"804","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"2","8":"NA","9":"NA","10":"NA"},{"1":"804","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"2","8":"NA","9":"NA","10":"NA"},{"1":"804","2":"2","3":"Not intubated","4":"0","5":"0","6":"0","7":"2","8":"NA","9":"NA","10":"NA"},{"1":"142","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"142","2":"1","3":"Not intubated","4":"0","5":"0","6":"1","7":"16","8":"1","9":"NA","10":"NA"},{"1":"142","2":"2","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"142","2":"3","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"142","2":"4","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"142","2":"5","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"142","2":"6","3":"Not intubated","4":"1","5":"0","6":"0","7":"16","8":"NA","9":"6","10":"NA"},{"1":"142","2":"7","3":"Not intubated","4":"1","5":"0","6":"0","7":"16","8":"NA","9":"7","10":"NA"},{"1":"142","2":"8","3":"Not intubated","4":"1","5":"0","6":"0","7":"16","8":"NA","9":"8","10":"NA"},{"1":"142","2":"9","3":"Not intubated","4":"1","5":"0","6":"0","7":"16","8":"NA","9":"9","10":"NA"},{"1":"142","2":"10","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"142","2":"11","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"142","2":"12","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"142","2":"13","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"142","2":"14","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"142","2":"15","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"142","2":"16","3":"Not intubated","4":"0","5":"1","6":"0","7":"16","8":"NA","9":"NA","10":"16"},{"1":"877","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"4","8":"NA","9":"NA","10":"NA"},{"1":"877","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"4","8":"NA","9":"NA","10":"NA"},{"1":"877","2":"2","3":"Not intubated","4":"0","5":"0","6":"0","7":"4","8":"NA","9":"NA","10":"NA"},{"1":"877","2":"3","3":"Not intubated","4":"0","5":"0","6":"0","7":"4","8":"NA","9":"NA","10":"NA"},{"1":"877","2":"4","3":"Not intubated","4":"0","5":"0","6":"0","7":"4","8":"NA","9":"NA","10":"NA"},{"1":"591","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"591","2":"1","3":"Intubated","4":"0","5":"0","6":"1","7":"11","8":"1","9":"NA","10":"NA"},{"1":"591","2":"2","3":"Intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"591","2":"3","3":"Intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"591","2":"4","3":"Intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"591","2":"5","3":"Intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"591","2":"6","3":"Not intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"591","2":"7","3":"Not intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"591","2":"8","3":"Not intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"591","2":"9","3":"Not intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"591","2":"10","3":"Not intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"591","2":"11","3":"Not intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"518","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"8","8":"NA","9":"NA","10":"NA"},{"1":"518","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"8","8":"NA","9":"NA","10":"NA"},{"1":"518","2":"2","3":"Not intubated","4":"0","5":"0","6":"0","7":"8","8":"NA","9":"NA","10":"NA"},{"1":"518","2":"3","3":"Not intubated","4":"0","5":"0","6":"0","7":"8","8":"NA","9":"NA","10":"NA"},{"1":"518","2":"4","3":"Not intubated","4":"0","5":"0","6":"0","7":"8","8":"NA","9":"NA","10":"NA"},{"1":"518","2":"5","3":"Not intubated","4":"0","5":"0","6":"0","7":"8","8":"NA","9":"NA","10":"NA"},{"1":"518","2":"6","3":"Not intubated","4":"0","5":"0","6":"0","7":"8","8":"NA","9":"NA","10":"NA"},{"1":"518","2":"7","3":"Not intubated","4":"0","5":"0","6":"0","7":"8","8":"NA","9":"NA","10":"NA"},{"1":"518","2":"8","3":"Not intubated","4":"0","5":"0","6":"0","7":"8","8":"NA","9":"NA","10":"NA"},{"1":"195","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"10","8":"NA","9":"NA","10":"NA"},{"1":"195","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"10","8":"NA","9":"NA","10":"NA"},{"1":"195","2":"2","3":"Not intubated","4":"0","5":"0","6":"0","7":"10","8":"NA","9":"NA","10":"NA"},{"1":"195","2":"3","3":"Not intubated","4":"0","5":"0","6":"1","7":"10","8":"3","9":"NA","10":"NA"},{"1":"195","2":"4","3":"Not intubated","4":"0","5":"0","6":"0","7":"10","8":"NA","9":"NA","10":"NA"},{"1":"195","2":"5","3":"Not intubated","4":"0","5":"0","6":"0","7":"10","8":"NA","9":"NA","10":"NA"},{"1":"195","2":"6","3":"Not intubated","4":"0","5":"0","6":"0","7":"10","8":"NA","9":"NA","10":"NA"},{"1":"195","2":"7","3":"Not intubated","4":"0","5":"0","6":"0","7":"10","8":"NA","9":"NA","10":"NA"},{"1":"195","2":"8","3":"Not intubated","4":"0","5":"0","6":"0","7":"10","8":"NA","9":"NA","10":"NA"},{"1":"195","2":"9","3":"Not intubated","4":"0","5":"0","6":"0","7":"10","8":"NA","9":"NA","10":"NA"},{"1":"195","2":"10","3":"Not intubated","4":"0","5":"0","6":"0","7":"10","8":"NA","9":"NA","10":"NA"},{"1":"776","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"19","8":"NA","9":"NA","10":"NA"},{"1":"776","2":"1","3":"Not intubated","4":"0","5":"0","6":"1","7":"19","8":"1","9":"NA","10":"NA"},{"1":"776","2":"2","3":"Not intubated","4":"0","5":"0","6":"0","7":"19","8":"NA","9":"NA","10":"NA"},{"1":"776","2":"3","3":"Not intubated","4":"0","5":"0","6":"0","7":"19","8":"NA","9":"NA","10":"NA"},{"1":"776","2":"4","3":"Not intubated","4":"0","5":"0","6":"0","7":"19","8":"NA","9":"NA","10":"NA"},{"1":"776","2":"5","3":"Not intubated","4":"0","5":"0","6":"0","7":"19","8":"NA","9":"NA","10":"NA"},{"1":"776","2":"6","3":"Not intubated","4":"0","5":"0","6":"0","7":"19","8":"NA","9":"NA","10":"NA"},{"1":"776","2":"7","3":"Not intubated","4":"0","5":"0","6":"0","7":"19","8":"NA","9":"NA","10":"NA"},{"1":"776","2":"8","3":"Not intubated","4":"0","5":"0","6":"0","7":"19","8":"NA","9":"NA","10":"NA"},{"1":"776","2":"9","3":"Not intubated","4":"0","5":"0","6":"0","7":"19","8":"NA","9":"NA","10":"NA"},{"1":"776","2":"10","3":"Not intubated","4":"0","5":"0","6":"0","7":"19","8":"NA","9":"NA","10":"NA"},{"1":"776","2":"11","3":"Not intubated","4":"0","5":"0","6":"0","7":"19","8":"NA","9":"NA","10":"NA"},{"1":"776","2":"12","3":"Not intubated","4":"0","5":"0","6":"0","7":"19","8":"NA","9":"NA","10":"NA"},{"1":"776","2":"13","3":"Not intubated","4":"0","5":"0","6":"0","7":"19","8":"NA","9":"NA","10":"NA"},{"1":"776","2":"14","3":"Not intubated","4":"0","5":"0","6":"0","7":"19","8":"NA","9":"NA","10":"NA"},{"1":"776","2":"15","3":"Not intubated","4":"0","5":"0","6":"0","7":"19","8":"NA","9":"NA","10":"NA"},{"1":"776","2":"16","3":"Not intubated","4":"0","5":"0","6":"0","7":"19","8":"NA","9":"NA","10":"NA"},{"1":"776","2":"17","3":"Not intubated","4":"0","5":"0","6":"0","7":"19","8":"NA","9":"NA","10":"NA"},{"1":"776","2":"18","3":"Not intubated","4":"0","5":"0","6":"0","7":"19","8":"NA","9":"NA","10":"NA"},{"1":"776","2":"19","3":"Not intubated","4":"0","5":"0","6":"0","7":"19","8":"NA","9":"NA","10":"NA"},{"1":"277","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"277","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"277","2":"2","3":"Not intubated","4":"0","5":"0","6":"1","7":"11","8":"2","9":"NA","10":"NA"},{"1":"277","2":"3","3":"Not intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"277","2":"4","3":"Not intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"277","2":"5","3":"Not intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"277","2":"6","3":"Not intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"277","2":"7","3":"Not intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"277","2":"8","3":"Not intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"277","2":"9","3":"Not intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"277","2":"10","3":"Not intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"277","2":"11","3":"Not intubated","4":"0","5":"0","6":"0","7":"11","8":"NA","9":"NA","10":"NA"},{"1":"378","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"2","8":"NA","9":"NA","10":"NA"},{"1":"378","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"2","8":"NA","9":"NA","10":"NA"},{"1":"378","2":"2","3":"Not intubated","4":"0","5":"0","6":"0","7":"2","8":"NA","9":"NA","10":"NA"},{"1":"677","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"4","8":"NA","9":"NA","10":"NA"},{"1":"677","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"4","8":"NA","9":"NA","10":"NA"},{"1":"677","2":"2","3":"Not intubated","4":"0","5":"0","6":"0","7":"4","8":"NA","9":"NA","10":"NA"},{"1":"677","2":"3","3":"Not intubated","4":"0","5":"0","6":"0","7":"4","8":"NA","9":"NA","10":"NA"},{"1":"677","2":"4","3":"Not intubated","4":"0","5":"0","6":"0","7":"4","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"2","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"3","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"4","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"5","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"6","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"7","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"8","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"9","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"10","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"11","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"12","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"13","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"14","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"15","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"16","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"17","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"18","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"19","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"20","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"21","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"878","2":"22","3":"Not intubated","4":"0","5":"0","6":"0","7":"22","8":"NA","9":"NA","10":"NA"},{"1":"101","2":"0","3":"Intubated","4":"0","5":"0","6":"1","7":"4","8":"0","9":"NA","10":"NA"},{"1":"101","2":"1","3":"Intubated","4":"0","5":"0","6":"0","7":"4","8":"NA","9":"NA","10":"NA"},{"1":"101","2":"2","3":"Intubated","4":"0","5":"0","6":"0","7":"4","8":"NA","9":"NA","10":"NA"},{"1":"101","2":"3","3":"Intubated","4":"0","5":"0","6":"0","7":"4","8":"NA","9":"NA","10":"NA"},{"1":"101","2":"4","3":"Intubated","4":"0","5":"1","6":"0","7":"4","8":"NA","9":"NA","10":"4"},{"1":"612","2":"0","3":"Intubated","4":"0","5":"0","6":"1","7":"28","8":"0","9":"NA","10":"NA"},{"1":"612","2":"1","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"2","3":"Intubated","4":"1","5":"0","6":"0","7":"28","8":"NA","9":"2","10":"NA"},{"1":"612","2":"3","3":"Intubated","4":"1","5":"0","6":"0","7":"28","8":"NA","9":"3","10":"NA"},{"1":"612","2":"4","3":"Intubated","4":"1","5":"0","6":"0","7":"28","8":"NA","9":"4","10":"NA"},{"1":"612","2":"5","3":"Intubated","4":"1","5":"0","6":"0","7":"28","8":"NA","9":"5","10":"NA"},{"1":"612","2":"6","3":"Intubated","4":"1","5":"0","6":"0","7":"28","8":"NA","9":"6","10":"NA"},{"1":"612","2":"7","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"8","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"9","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"10","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"11","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"12","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"13","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"14","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"15","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"16","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"17","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"18","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"19","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"20","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"21","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"22","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"23","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"24","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"25","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"26","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"27","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"612","2":"28","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"625","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"3","8":"NA","9":"NA","10":"NA"},{"1":"625","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"3","8":"NA","9":"NA","10":"NA"},{"1":"625","2":"2","3":"Not intubated","4":"0","5":"0","6":"0","7":"3","8":"NA","9":"NA","10":"NA"},{"1":"625","2":"3","3":"Not intubated","4":"0","5":"0","6":"0","7":"3","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"2","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"3","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"4","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"5","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"6","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"7","3":"Not intubated","4":"0","5":"0","6":"1","7":"28","8":"7","9":"NA","10":"NA"},{"1":"178","2":"8","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"9","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"10","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"11","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"12","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"13","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"14","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"15","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"16","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"17","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"18","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"19","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"20","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"21","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"22","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"23","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"24","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"25","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"26","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"27","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"178","2":"28","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"1","3":"Not intubated","4":"0","5":"0","6":"1","7":"28","8":"1","9":"NA","10":"NA"},{"1":"474","2":"2","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"3","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"4","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"5","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"6","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"7","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"8","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"9","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"10","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"11","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"12","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"13","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"14","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"15","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"16","3":"Intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"17","3":"Intubated","4":"1","5":"0","6":"0","7":"28","8":"NA","9":"17","10":"NA"},{"1":"474","2":"18","3":"Intubated","4":"1","5":"0","6":"0","7":"28","8":"NA","9":"18","10":"NA"},{"1":"474","2":"19","3":"Intubated","4":"1","5":"0","6":"0","7":"28","8":"NA","9":"19","10":"NA"},{"1":"474","2":"20","3":"Intubated","4":"1","5":"0","6":"0","7":"28","8":"NA","9":"20","10":"NA"},{"1":"474","2":"21","3":"Intubated","4":"1","5":"0","6":"0","7":"28","8":"NA","9":"21","10":"NA"},{"1":"474","2":"22","3":"Not intubated","4":"1","5":"0","6":"0","7":"28","8":"NA","9":"22","10":"NA"},{"1":"474","2":"23","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"24","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"25","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"26","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"27","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"474","2":"28","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"2","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"3","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"4","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"5","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"6","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"7","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"8","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"9","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"10","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"11","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"12","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"13","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"14","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"15","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"16","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"17","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"18","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"19","3":"Not intubated","4":"0","5":"0","6":"1","7":"28","8":"19","9":"NA","10":"NA"},{"1":"430","2":"20","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"21","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"22","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"23","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"24","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"25","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"26","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"27","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"430","2":"28","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"767","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"1","8":"NA","9":"NA","10":"NA"},{"1":"767","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"1","8":"NA","9":"NA","10":"NA"},{"1":"960","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"3","8":"NA","9":"NA","10":"NA"},{"1":"960","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"3","8":"NA","9":"NA","10":"NA"},{"1":"960","2":"2","3":"Not intubated","4":"0","5":"0","6":"0","7":"3","8":"NA","9":"NA","10":"NA"},{"1":"960","2":"3","3":"Not intubated","4":"0","5":"0","6":"0","7":"3","8":"NA","9":"NA","10":"NA"},{"1":"389","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"21","8":"NA","9":"NA","10":"NA"},{"1":"389","2":"1","3":"Intubated","4":"0","5":"0","6":"1","7":"21","8":"1","9":"NA","10":"NA"},{"1":"389","2":"2","3":"Intubated","4":"0","5":"0","6":"0","7":"21","8":"NA","9":"NA","10":"NA"},{"1":"389","2":"3","3":"Intubated","4":"0","5":"0","6":"0","7":"21","8":"NA","9":"NA","10":"NA"},{"1":"389","2":"4","3":"Intubated","4":"0","5":"0","6":"0","7":"21","8":"NA","9":"NA","10":"NA"},{"1":"389","2":"5","3":"Intubated","4":"0","5":"0","6":"0","7":"21","8":"NA","9":"NA","10":"NA"},{"1":"389","2":"6","3":"Intubated","4":"0","5":"0","6":"0","7":"21","8":"NA","9":"NA","10":"NA"},{"1":"389","2":"7","3":"Intubated","4":"0","5":"0","6":"0","7":"21","8":"NA","9":"NA","10":"NA"},{"1":"389","2":"8","3":"Intubated","4":"0","5":"0","6":"0","7":"21","8":"NA","9":"NA","10":"NA"},{"1":"389","2":"9","3":"Intubated","4":"0","5":"0","6":"0","7":"21","8":"NA","9":"NA","10":"NA"},{"1":"389","2":"10","3":"Intubated","4":"0","5":"0","6":"0","7":"21","8":"NA","9":"NA","10":"NA"},{"1":"389","2":"11","3":"Intubated","4":"1","5":"0","6":"0","7":"21","8":"NA","9":"11","10":"NA"},{"1":"389","2":"12","3":"Intubated","4":"1","5":"0","6":"0","7":"21","8":"NA","9":"12","10":"NA"},{"1":"389","2":"13","3":"Intubated","4":"1","5":"0","6":"0","7":"21","8":"NA","9":"13","10":"NA"},{"1":"389","2":"14","3":"Intubated","4":"1","5":"0","6":"0","7":"21","8":"NA","9":"14","10":"NA"},{"1":"389","2":"15","3":"Not intubated","4":"1","5":"0","6":"0","7":"21","8":"NA","9":"15","10":"NA"},{"1":"389","2":"16","3":"Not intubated","4":"1","5":"0","6":"0","7":"21","8":"NA","9":"16","10":"NA"},{"1":"389","2":"17","3":"Not intubated","4":"1","5":"0","6":"0","7":"21","8":"NA","9":"17","10":"NA"},{"1":"389","2":"18","3":"Not intubated","4":"1","5":"0","6":"0","7":"21","8":"NA","9":"18","10":"NA"},{"1":"389","2":"19","3":"Not intubated","4":"0","5":"0","6":"0","7":"21","8":"NA","9":"NA","10":"NA"},{"1":"389","2":"20","3":"Not intubated","4":"0","5":"0","6":"0","7":"21","8":"NA","9":"NA","10":"NA"},{"1":"389","2":"21","3":"Not intubated","4":"0","5":"0","6":"0","7":"21","8":"NA","9":"NA","10":"NA"},{"1":"187","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"3","8":"NA","9":"NA","10":"NA"},{"1":"187","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"3","8":"NA","9":"NA","10":"NA"},{"1":"187","2":"2","3":"Not intubated","4":"0","5":"0","6":"0","7":"3","8":"NA","9":"NA","10":"NA"},{"1":"187","2":"3","3":"Not intubated","4":"0","5":"0","6":"0","7":"3","8":"NA","9":"NA","10":"NA"},{"1":"600","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"10","8":"NA","9":"NA","10":"NA"},{"1":"600","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"10","8":"NA","9":"NA","10":"NA"},{"1":"600","2":"2","3":"Not intubated","4":"0","5":"0","6":"1","7":"10","8":"2","9":"NA","10":"NA"},{"1":"600","2":"3","3":"Not intubated","4":"0","5":"0","6":"0","7":"10","8":"NA","9":"NA","10":"NA"},{"1":"600","2":"4","3":"Not intubated","4":"0","5":"0","6":"0","7":"10","8":"NA","9":"NA","10":"NA"},{"1":"600","2":"5","3":"Not intubated","4":"0","5":"0","6":"0","7":"10","8":"NA","9":"NA","10":"NA"},{"1":"600","2":"6","3":"Not intubated","4":"0","5":"0","6":"0","7":"10","8":"NA","9":"NA","10":"NA"},{"1":"600","2":"7","3":"Not intubated","4":"0","5":"0","6":"0","7":"10","8":"NA","9":"NA","10":"NA"},{"1":"600","2":"8","3":"Not intubated","4":"0","5":"0","6":"0","7":"10","8":"NA","9":"NA","10":"NA"},{"1":"600","2":"9","3":"Not intubated","4":"0","5":"0","6":"0","7":"10","8":"NA","9":"NA","10":"NA"},{"1":"600","2":"10","3":"Not intubated","4":"0","5":"0","6":"0","7":"10","8":"NA","9":"NA","10":"NA"},{"1":"156","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"1","8":"NA","9":"NA","10":"NA"},{"1":"156","2":"1","3":"Not intubated","4":"0","5":"1","6":"0","7":"1","8":"NA","9":"NA","10":"1"},{"1":"705","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"705","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"705","2":"2","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"705","2":"3","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"705","2":"4","3":"Not intubated","4":"0","5":"0","6":"1","7":"16","8":"4","9":"NA","10":"NA"},{"1":"705","2":"5","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"705","2":"6","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"705","2":"7","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"705","2":"8","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"705","2":"9","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"705","2":"10","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"705","2":"11","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"705","2":"12","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"705","2":"13","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"705","2":"14","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"705","2":"15","3":"Not intubated","4":"0","5":"0","6":"0","7":"16","8":"NA","9":"NA","10":"NA"},{"1":"705","2":"16","3":"Not intubated","4":"0","5":"1","6":"0","7":"16","8":"NA","9":"NA","10":"16"},{"1":"784","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"4","8":"NA","9":"NA","10":"NA"},{"1":"784","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"4","8":"NA","9":"NA","10":"NA"},{"1":"784","2":"2","3":"Not intubated","4":"0","5":"0","6":"0","7":"4","8":"NA","9":"NA","10":"NA"},{"1":"784","2":"3","3":"Not intubated","4":"0","5":"0","6":"0","7":"4","8":"NA","9":"NA","10":"NA"},{"1":"784","2":"4","3":"Not intubated","4":"0","5":"0","6":"0","7":"4","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"2","3":"Not intubated","4":"0","5":"0","6":"1","7":"28","8":"2","9":"NA","10":"NA"},{"1":"664","2":"3","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"4","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"5","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"6","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"7","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"8","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"9","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"10","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"11","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"12","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"13","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"14","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"15","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"16","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"17","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"18","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"19","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"20","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"21","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"22","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"23","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"24","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"25","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"26","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"27","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"664","2":"28","3":"Not intubated","4":"0","5":"0","6":"0","7":"28","8":"NA","9":"NA","10":"NA"},{"1":"373","2":"0","3":"Not intubated","4":"0","5":"0","6":"0","7":"2","8":"NA","9":"NA","10":"NA"},{"1":"373","2":"1","3":"Not intubated","4":"0","5":"0","6":"0","7":"2","8":"NA","9":"NA","10":"NA"},{"1":"373","2":"2","3":"Not intubated","4":"0","5":"0","6":"0","7":"2","8":"NA","9":"NA","10":"NA"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}} </script> </div> --- count: false # Step 3: Plot all your geometries .panel1-swim0-user[ ```r *dat_swim %>% * ggplot(aes(y=id, group=id)) ``` ] .panel2-swim0-user[ ![](slides_files/figure-html/swim0_user_01_output-1.png)<!-- --> ] --- count: false # Step 3: Plot all your geometries .panel1-swim0-user[ ```r dat_swim %>% ggplot(aes(y=id, group=id)) + * theme_bw() ``` ] .panel2-swim0-user[ ![](slides_files/figure-html/swim0_user_02_output-1.png)<!-- --> ] --- count: false # Step 3: Plot all your geometries .panel1-swim0-user[ ```r dat_swim %>% ggplot(aes(y=id, group=id)) + theme_bw() + * geom_line(aes(x=day, col = intubation_status)) ``` ] .panel2-swim0-user[ ![](slides_files/figure-html/swim0_user_03_output-1.png)<!-- --> ] --- count: false # Step 3: Plot all your geometries .panel1-swim0-user[ ```r dat_swim %>% ggplot(aes(y=id, group=id)) + theme_bw() + geom_line(aes(x=day, col = intubation_status)) + * geom_point(aes(x=steroids_this_day)) ``` ] .panel2-swim0-user[ ![](slides_files/figure-html/swim0_user_04_output-1.png)<!-- --> ] --- count: false # Step 3: Plot all your geometries .panel1-swim0-user[ ```r dat_swim %>% ggplot(aes(y=id, group=id)) + theme_bw() + geom_line(aes(x=day, col = intubation_status)) + geom_point(aes(x=steroids_this_day)) + * geom_point(aes(x=severe_this_day)) ``` ] .panel2-swim0-user[ ![](slides_files/figure-html/swim0_user_05_output-1.png)<!-- --> ] --- count: false # Step 3: Plot all your geometries .panel1-swim0-user[ ```r dat_swim %>% ggplot(aes(y=id, group=id)) + theme_bw() + geom_line(aes(x=day, col = intubation_status)) + geom_point(aes(x=steroids_this_day)) + geom_point(aes(x=severe_this_day)) + * geom_point(aes(x=death_this_day)) ``` ] .panel2-swim0-user[ ![](slides_files/figure-html/swim0_user_06_output-1.png)<!-- --> ] <style> .panel1-swim0-user { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-swim0-user { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-swim0-user { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false # Step 4: Modify geom_* layers. .panel1-swim1-user[ ```r *dat_swim %>% * ggplot(aes(y=id, group=id)) + * theme_bw() ``` ] .panel2-swim1-user[ ![](slides_files/figure-html/swim1_user_01_output-1.png)<!-- --> ] --- count: false # Step 4: Modify geom_* layers. .panel1-swim1-user[ ```r dat_swim %>% ggplot(aes(y=id, group=id)) + theme_bw() + * geom_line(aes(x=day, col = intubation_status), * size=1.8) ``` ] .panel2-swim1-user[ ![](slides_files/figure-html/swim1_user_02_output-1.png)<!-- --> ] --- count: false # Step 4: Modify geom_* layers. .panel1-swim1-user[ ```r dat_swim %>% ggplot(aes(y=id, group=id)) + theme_bw() + geom_line(aes(x=day, col = intubation_status), size=1.8) + * geom_point(aes(x=steroids_this_day), * stroke=2, * shape = 15) ``` ] .panel2-swim1-user[ ![](slides_files/figure-html/swim1_user_03_output-1.png)<!-- --> ] --- count: false # Step 4: Modify geom_* layers. .panel1-swim1-user[ ```r dat_swim %>% ggplot(aes(y=id, group=id)) + theme_bw() + geom_line(aes(x=day, col = intubation_status), size=1.8) + geom_point(aes(x=steroids_this_day), stroke=2, shape = 15) + * geom_point(aes(x=severe_this_day), * size=2, * stroke=1.5, * shape = 21) ``` ] .panel2-swim1-user[ ![](slides_files/figure-html/swim1_user_04_output-1.png)<!-- --> ] --- count: false # Step 4: Modify geom_* layers. .panel1-swim1-user[ ```r dat_swim %>% ggplot(aes(y=id, group=id)) + theme_bw() + geom_line(aes(x=day, col = intubation_status), size=1.8) + geom_point(aes(x=steroids_this_day), stroke=2, shape = 15) + geom_point(aes(x=severe_this_day), size=2, stroke=1.5, shape = 21) + * geom_point(aes(x=death_this_day), * size=2, * stroke=1.5, * shape = 4) ``` ] .panel2-swim1-user[ ![](slides_files/figure-html/swim1_user_05_output-1.png)<!-- --> ] <style> .panel1-swim1-user { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-swim1-user { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-swim1-user { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- # Step 5: Add colors and legend .left-column[ ![](img/bear_with_me.jpg) ] .right-column[ **The Big Picture:** - We want a legend which correctly maps each shape, color, and line type to the corresponding status. - We need all of our statuses to show up in the legend. They currently do not, because they're not being mapped to an `aes`thetic argument. - We will force all the statuses to show up by creating a new aesthetic (color) which **corresponds to the name we want each status to be labeled** in the legend. - We will then modify this legend for "color" to also contain information about shape, linetype, etc. for each status. ] --- count: false # Step 5: Add colors and legend .panel1-swim2-user[ ```r *dat_swim %>% * ggplot(aes(y=id)) + * theme_bw() + * geom_line(aes(x=day, * col = intubation_status, * group=id), * size=1.8) ``` ] .panel2-swim2-user[ ![](slides_files/figure-html/swim2_user_01_output-1.png)<!-- --> ] --- count: false # Step 5: Add colors and legend .panel1-swim2-user[ ```r dat_swim %>% ggplot(aes(y=id)) + theme_bw() + geom_line(aes(x=day, col = intubation_status, group=id), size=1.8) + * geom_point(aes(x=steroids_this_day, * col="Steroids"), * stroke=2, * shape=15) ``` ] .panel2-swim2-user[ ![](slides_files/figure-html/swim2_user_02_output-1.png)<!-- --> ] --- count: false # Step 5: Add colors and legend .panel1-swim2-user[ ```r dat_swim %>% ggplot(aes(y=id)) + theme_bw() + geom_line(aes(x=day, col = intubation_status, group=id), size=1.8) + geom_point(aes(x=steroids_this_day, col="Steroids"), stroke=2, shape=15) + * geom_point(aes(x=severe_this_day, * col="Severe hypoxia"), * size=2, * stroke=1.5, * shape=21) ``` ] .panel2-swim2-user[ ![](slides_files/figure-html/swim2_user_03_output-1.png)<!-- --> ] --- count: false # Step 5: Add colors and legend .panel1-swim2-user[ ```r dat_swim %>% ggplot(aes(y=id)) + theme_bw() + geom_line(aes(x=day, col = intubation_status, group=id), size=1.8) + geom_point(aes(x=steroids_this_day, col="Steroids"), stroke=2, shape=15) + geom_point(aes(x=severe_this_day, col="Severe hypoxia"), size=2, stroke=1.5, shape=21) + * geom_point(aes(x=death_this_day, * col="Death"), * size=2, * stroke=1.5, * shape=4) ``` ] .panel2-swim2-user[ ![](slides_files/figure-html/swim2_user_04_output-1.png)<!-- --> ] <style> .panel1-swim2-user { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-swim2-user { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-swim2-user { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- # Step 6: Modify colors - We now need a key for status labels and corresponding colors. ```r # define colors for all geometries with a color argument cols <- c("Severe hypoxia" = "#b24745", # red "Intubated" = "#483d8b", # navy "Not intubated" = "#74aaff", # blue "Steroids"="#ffd966", # gold "Death" = "#000000") # black ``` - The label of the status should match the label inputted to `aes(col = "...")`. - The order of this color key will be the order the statuses appear in the legend. - We will use this key as the `values` argument of `scale_color_manual()`: --- count: false # Step 6: Modify colors .panel1-swim3-user[ ```r *dat_swim %>% * ggplot(aes(y=id)) + * theme_bw() + * geom_line(aes(x=day, * col = intubation_status, * group=id), * size=1.8) + * geom_point(aes(x=steroids_this_day, * col="Steroids"), * stroke=2, * shape=15) + * geom_point(aes(x=severe_this_day, * col="Severe hypoxia"), * size=2, * stroke=1.5, * shape=21) + * geom_point(aes(x=death_this_day, * col="Death"), * size=2, * stroke=1.5, * shape=4) ``` ] .panel2-swim3-user[ ![](slides_files/figure-html/swim3_user_01_output-1.png)<!-- --> ] --- count: false # Step 6: Modify colors .panel1-swim3-user[ ```r dat_swim %>% ggplot(aes(y=id)) + theme_bw() + geom_line(aes(x=day, col = intubation_status, group=id), size=1.8) + geom_point(aes(x=steroids_this_day, col="Steroids"), stroke=2, shape=15) + geom_point(aes(x=severe_this_day, col="Severe hypoxia"), size=2, stroke=1.5, shape=21) + geom_point(aes(x=death_this_day, col="Death"), size=2, stroke=1.5, shape=4) + * scale_color_manual(values = cols, * name="Patient Status") ``` ] .panel2-swim3-user[ ![](slides_files/figure-html/swim3_user_02_output-1.png)<!-- --> ] <style> .panel1-swim3-user { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-swim3-user { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-swim3-user { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- # Step 7: Modify legend using override.aes() - We need to create vectors for overriding the aesthetics for `shape`, `linetype`, `stroke`, and `size` in the current "color" legend. - These should be in the same order as the `cols` key - If we don't want a certain aesthetic to show up (e.g. no shape for intubation), we use `NA` ```r cols ``` ``` Severe hypoxia Intubated Not intubated Steroids Death "#b24745" "#483d8b" "#74aaff" "#ffd966" "#000000" ``` ```r shape_override <- c(21, NA, NA, 15, 4) # order matches `cols`:severe, intubation (yes/no), steroids, death line_override <- c(NA,1,1,NA,NA) # order matches `cols`:severe, intubation (yes/no), steroids, death stroke_override <- c(.8,1,1,1,1) # order matches `cols`:severe, intubation (yes/no), steroids, death size_override <- c(2.5,2.5,2.6,2,2) # order matches `cols`:severe, intubation (yes/no), steroids, death ``` --- count: false # Step 7: Modify legend using override.aes() .panel1-swim4-user[ ```r *dat_swim %>% * ggplot(aes(y=id)) + * theme_bw() + * geom_line(aes(x=day, col = intubation_status, group=id), * size=1.8) + * geom_point(aes(x=steroids_this_day, col="Steroids"), * stroke=2, shape=15) + * geom_point(aes(x=severe_this_day, col="Severe hypoxia"), * size=2, stroke=1.5, shape=21) + * geom_point(aes(x=death_this_day, col="Death"), * size=2, stroke=1.5, shape=4) + * scale_color_manual(values = cols, * name="Patient Status") ``` ] .panel2-swim4-user[ ![](slides_files/figure-html/swim4_user_01_output-1.png)<!-- --> ] --- count: false # Step 7: Modify legend using override.aes() .panel1-swim4-user[ ```r dat_swim %>% ggplot(aes(y=id)) + theme_bw() + geom_line(aes(x=day, col = intubation_status, group=id), size=1.8) + geom_point(aes(x=steroids_this_day, col="Steroids"), stroke=2, shape=15) + geom_point(aes(x=severe_this_day, col="Severe hypoxia"), size=2, stroke=1.5, shape=21) + geom_point(aes(x=death_this_day, col="Death"), size=2, stroke=1.5, shape=4) + scale_color_manual(values = cols, name="Patient Status") + * guides(color = guide_legend( * override.aes = list( * stroke = stroke_override, * size = size_override, * shape = shape_override, * linetype = line_override) * )) ``` ] .panel2-swim4-user[ ![](slides_files/figure-html/swim4_user_02_output-1.png)<!-- --> ] <style> .panel1-swim4-user { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-swim4-user { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-swim4-user { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false # Step 8: Make minor theme edits .panel1-swim5-user[ ```r *p + labs(x="Days since hospitalization", * y="Patient\nnumber", * title="Treatment Timeline for N=30 Patients") ``` ] .panel2-swim5-user[ ![](slides_files/figure-html/swim5_user_01_output-1.png)<!-- --> ] --- count: false # Step 8: Make minor theme edits .panel1-swim5-user[ ```r p + labs(x="Days since hospitalization", y="Patient\nnumber", title="Treatment Timeline for N=30 Patients") + * scale_x_continuous(expand=c(0,0)) ``` ] .panel2-swim5-user[ ![](slides_files/figure-html/swim5_user_02_output-1.png)<!-- --> ] --- count: false # Step 8: Make minor theme edits .panel1-swim5-user[ ```r p + labs(x="Days since hospitalization", y="Patient\nnumber", title="Treatment Timeline for N=30 Patients") + scale_x_continuous(expand=c(0,0)) + * theme(text=element_text(family="Poppins", size=11)) + * theme(title = element_text(angle = 0, vjust=.5, * size=12, face="bold"), * axis.title.y = element_text(angle = 0, vjust=.5, * size=12, face="bold"), * axis.title.x = element_text(size=15, face="bold", * vjust=-0.5, hjust=0), * axis.text.y = element_text(size=6, * hjust=1.5), * axis.ticks.y = element_blank()) ``` ] .panel2-swim5-user[ ![](slides_files/figure-html/swim5_user_03_output-1.png)<!-- --> ] --- count: false # Step 8: Make minor theme edits .panel1-swim5-user[ ```r p + labs(x="Days since hospitalization", y="Patient\nnumber", title="Treatment Timeline for N=30 Patients") + scale_x_continuous(expand=c(0,0)) + theme(text=element_text(family="Poppins", size=11)) + theme(title = element_text(angle = 0, vjust=.5, size=12, face="bold"), axis.title.y = element_text(angle = 0, vjust=.5, size=12, face="bold"), axis.title.x = element_text(size=15, face="bold", vjust=-0.5, hjust=0), axis.text.y = element_text(size=6, hjust=1.5), axis.ticks.y = element_blank()) + * theme(legend.position = c(0.8, 0.3), * legend.title = element_text(colour="black", * size=13, * face=4), * legend.text = element_text(colour="black", * size=10), * legend.background = element_rect(size=0.5, * linetype="solid", * colour ="gray30")) ``` ] .panel2-swim5-user[ ![](slides_files/figure-html/swim5_user_04_output-1.png)<!-- --> ] --- count: false # Step 8: Make minor theme edits .panel1-swim5-user[ ```r p + labs(x="Days since hospitalization", y="Patient\nnumber", title="Treatment Timeline for N=30 Patients") + scale_x_continuous(expand=c(0,0)) + theme(text=element_text(family="Poppins", size=11)) + theme(title = element_text(angle = 0, vjust=.5, size=12, face="bold"), axis.title.y = element_text(angle = 0, vjust=.5, size=12, face="bold"), axis.title.x = element_text(size=15, face="bold", vjust=-0.5, hjust=0), axis.text.y = element_text(size=6, hjust=1.5), axis.ticks.y = element_blank()) + theme(legend.position = c(0.8, 0.3), legend.title = element_text(colour="black", size=13, face=4), legend.text = element_text(colour="black", size=10), legend.background = element_rect(size=0.5, linetype="solid", colour ="gray30")) + * theme(panel.grid.minor = element_blank(), * panel.grid.major.x = element_blank() * ) ``` ] .panel2-swim5-user[ ![](slides_files/figure-html/swim5_user_05_output-1.png)<!-- --> ] <style> .panel1-swim5-user { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-swim5-user { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-swim5-user { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- # In Summary 🏊 .pull-left[ - Long-format plotting data will need to have one column per status per row which indicates the **time of the status marker** to be denoted. - Once data is properly formatted, `ggplot` can be used to make customizable swimmer plots with the `geom_line` and `geom_point` layers. - The legend can be properly configured using the `override.aes()` argument in `guides()`. - These ideas can be extended in many ways, such as [**showing the pattern of missing data**](https://www.khstats.com/blog/trt-timelines/trt-timelines/). ] -- .pull-right[ <div class="figure"> <img src="img/trt-timeline-missing.png" alt="Image from Patient Treatment Timelines for Longitudinal Survival Data -- KHstats, 2019" width="400" /> <p class="caption">Image from Patient Treatment Timelines for Longitudinal Survival Data -- KHstats, 2019</p> </div> ] <!-- adjust font size in this css code chunk, currently 80 --> <style type="text/css"> .remark-code{line-height: 1.5; font-size: 80%} @media print { .has-continuation { display: block; } } code.r.hljs.remark-code{ position: relative; overflow-x: hidden; } code.r.hljs.remark-code:hover{ overflow-x:visible; width: 500px; border-style: solid; } </style> --- class: middle, center Thank you to the authors of `{xaringan}` and `{flipbookr}` for making these slides possible. <br> <br> <br> [
khstats.com](https://khstats.com) [
@kat\_hoffman\_](http://twitter.com/kat_hoffman_) [
@kathoffman](http://github.com/kathoffman) [
kathoffman.stats@gmail.com](mailto:kathoffman.stats@gmail.com) <img src="img/climbing_comic.jpeg" width="250"/>