Skip to content

Commit 988bb1f

Browse files
authored
Merge pull request #4 from opensafely/milanwiedemann/measures-suggestions
Suggestions for improving plotting measures
2 parents f6eb975 + c8544c1 commit 988bb1f

File tree

6 files changed

+44
-49
lines changed

6 files changed

+44
-49
lines changed

analysis/dataset_definition.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

analysis/stata.do

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
plot_measures <- function(
2+
data,
3+
title = NULL,
4+
x_label = NULL,
5+
y_label = NULL) {
6+
7+
# Create plot
8+
plot <- ggplot(
9+
data,
10+
aes(
11+
x = interval_end,
12+
y = numerator,
13+
color = measure,
14+
group = measure
15+
)
16+
) +
17+
geom_line() +
18+
labs(
19+
title = title,
20+
x = x_label,
21+
y = y_label,
22+
color = "Condition"
23+
) +
24+
# Setting the minimum y-value
25+
ylim(y_min, NA) +
26+
# Applying the minimal theme
27+
theme_minimal()
28+
29+
# Return plot
30+
plot
31+
}

lib/functions/graph_func.R

Lines changed: 0 additions & 18 deletions
This file was deleted.

lib/functions/visualise_data.R renamed to lib/functions/sketch.R

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1+
# In this file we're trying out some code
12
library(tidyverse)
23
library(ggplot2)
3-
library(gridExtra) # For arranging multiple plots
4+
library(gridExtra) # For arranging multiple plots
45

56
# Load data
67
df_measures <- readr::read_csv(
78
here::here("output", "report", "conditions_measures.csv")
89
)
10+
11+
# Develop plotting function
912
p <- ggplot(df_measures, aes(x = interval_end, y = numerator, color = measure, group = measure)) +
10-
geom_line() +
11-
labs(title = paste("Number of Consultations for each Pharmacy First Clinical Condition per month"),
12-
x = "Date",
13-
y = "Number of Consultations",
14-
color = "Condition") +
15-
ylim(0, NA)
16-
theme_minimal()
17-
13+
geom_line() +
14+
labs(
15+
title = paste("Number of Consultations for each Pharmacy First Clinical Condition per month"),
16+
x = "Date",
17+
y = "Number of Consultations",
18+
color = "Condition"
19+
) +
20+
ylim(0, NA)
21+
1822
source(here::here("lib", "functions", "graph_func.R"))
1923
plot1_conditions <- plot_pharmacy_first_conditions(df_measures)
20-

project.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ expectations:
55
population_size: 1000
66

77
actions:
8-
generate_dataset:
9-
run: ehrql:v1 generate-dataset analysis/dataset_definition.py --output output/dataset.csv.gz
10-
outputs:
11-
highly_sensitive:
12-
dataset: output/dataset.csv.gz
13-
148
generate_pf_measures:
159
run: >
1610
ehrql:v1 generate-measures analysis/report_measures.py

0 commit comments

Comments
 (0)