Skip to content

Commit 1f68d8b

Browse files
committed
update with new data
1 parent 4319fce commit 1f68d8b

21 files changed

+5746
-4762
lines changed

inst/tutorials/Lesson1/Lesson1.Rmd

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ library(here)
1818
knitr::opts_chunk$set(echo = TRUE)
1919
2020
consultations_gp <- read_delim(
21-
here("tutorials", "Lesson1", "data", "consultations_cleaned_2024-08-13.txt"),
21+
here("inst", "tutorials", "Lesson1", "data", "consultations_cleaned_2025-08-08.txt"),
2222
delim = "\t",
2323
show_col_types = FALSE
2424
)
@@ -59,11 +59,22 @@ my_plot1_nicer <- my_plot1 +
5959
```
6060

6161

62-
## Setup
62+
## Introduction and setup
6363

64-
Load the necessary libraries
64+
This tutorial can be followed in two ways:
65+
66+
- write and run the code in the boxes provided here,
67+
- create your own project, write a script and execute.
68+
69+
If you choose the first option, you don't need to load the data nor libraries,
70+
if you want the other option, download the data from
71+
[the source](https://github.com/jromanowska/RMED-ggplot-tutorial/tree/main/inst/tutorials/Lesson1/data),
72+
install and load the libraries.
73+
74+
We will be using {here}, {tidyverse}, and {patchwork}.
6575

6676
```{r}
77+
library(here)
6778
library(tidyverse)
6879
library(patchwork)
6980
```
@@ -77,22 +88,22 @@ A plot in `ggplot2` consists of several layers:
7788
- one row per datapoint
7889
- all grouping must be included in the data
7990

80-
2. aesthetics (`aes`) ([original documentation](https://ggplot2.tidyverse.org/reference/index.html#section-aesthetics))
91+
2. aesthetics (`aes`) ([original documentation](https://ggplot2.tidyverse.org/reference/index.html#aesthetics))
8192
- how to map the data to the graph?
8293
- which column is *x*, *y*, ...
8394
- which column provides grouping (based on the grouping, one can either connect points into lines, split a graph into several facets, or color differently each group)
8495

85-
3. `geom`s ([original documentation](https://ggplot2.tidyverse.org/reference/index.html#section-geoms))
96+
3. `geom`s ([original documentation](https://ggplot2.tidyverse.org/reference/index.html#geoms))
8697
- how to visualize the data?
8798
- points (`geom_point`), lines (`geom_line`), bars (`geom_bar`), etc.
8899
- `geom`s are connected to `stat`s that conduct any necessary pre-processing of data (e.g., `geom_histogram` would first calculate the number of observations in each bin through `stat_bin`)
89100

90-
4. `scale`s ([original documentation](https://ggplot2.tidyverse.org/reference/index.html#section-scales))
101+
4. `scale`s ([original documentation](https://ggplot2.tidyverse.org/reference/index.html#scales))
91102
- any type of data representation on the plot
92103
- coordinates: `scale_x_continuous`, `scale_x_discrete`, `scale_x_date`, etc.
93104
- colors: `scale_color_manual`, `scale_colour_brewer`, `scale_fill_continuous`, etc.
94105

95-
5. `theme` ([original documentation](https://ggplot2.tidyverse.org/reference/index.html#section-themes))
106+
5. `theme` ([original documentation](https://ggplot2.tidyverse.org/reference/index.html#themes))
96107
- visual aspects
97108
- size and types of fonts
98109
- positioning of axes, legends, etc.
@@ -105,13 +116,18 @@ Let's read in some data.
105116

106117
```{r, eval=FALSE}
107118
consultations_gp <- read_delim(
108-
here("data", "consultations_cleaned_2024-08-13.txt"),
119+
here("data", "consultations_cleaned_2025-08-08.txt"),
109120
delim = "\t"
110121
)
111122
consultations_gp
112123
```
113124

114-
This is publicly available data from SSB (Norwegian Statistics Bureau) on number of consultations at general practitioners (GP) between 2012 and 2021.
125+
```{r, echo=FALSE}
126+
consultations_gp
127+
```
128+
129+
130+
This is publicly available data from SSB (Norwegian Statistics Bureau) on number of consultations at general practitioners (GP) between 2012 and 2024.
115131

116132
Let's plot some numbers: total number of patients per year and per group ("diagnosis").
117133

64.1 KB
Loading
-6.18 KB
Loading
-5.39 KB
Loading
6.61 KB
Loading
-1 KB
Loading
42.4 KB
Loading
40.3 KB
Loading
-1.2 KB
Loading
-1.42 KB
Loading

0 commit comments

Comments
 (0)