Skip to content

Commit

Permalink
Merge pull request #4 from opensafely/milanwiedemann/measures-suggest…
Browse files Browse the repository at this point in the history
…ions

Suggestions for improving plotting measures
  • Loading branch information
viv3ckj authored Aug 21, 2024
2 parents f6eb975 + c8544c1 commit 988bb1f
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 49 deletions.
14 changes: 0 additions & 14 deletions analysis/dataset_definition.py

This file was deleted.

1 change: 0 additions & 1 deletion analysis/stata.do

This file was deleted.

31 changes: 31 additions & 0 deletions lib/functions/function_plot_measures.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
plot_measures <- function(
data,
title = NULL,
x_label = NULL,
y_label = NULL) {

# Create plot
plot <- ggplot(
data,
aes(
x = interval_end,
y = numerator,
color = measure,
group = measure
)
) +
geom_line() +
labs(
title = title,
x = x_label,
y = y_label,
color = "Condition"
) +
# Setting the minimum y-value
ylim(y_min, NA) +
# Applying the minimal theme
theme_minimal()

# Return plot
plot
}
18 changes: 0 additions & 18 deletions lib/functions/graph_func.R

This file was deleted.

23 changes: 13 additions & 10 deletions lib/functions/visualise_data.R → lib/functions/sketch.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# In this file we're trying out some code
library(tidyverse)
library(ggplot2)
library(gridExtra) # For arranging multiple plots
library(gridExtra) # For arranging multiple plots

# Load data
df_measures <- readr::read_csv(
here::here("output", "report", "conditions_measures.csv")
)

# Develop plotting function
p <- ggplot(df_measures, aes(x = interval_end, y = numerator, color = measure, group = measure)) +
geom_line() +
labs(title = paste("Number of Consultations for each Pharmacy First Clinical Condition per month"),
x = "Date",
y = "Number of Consultations",
color = "Condition") +
ylim(0, NA)
theme_minimal()

geom_line() +
labs(
title = paste("Number of Consultations for each Pharmacy First Clinical Condition per month"),
x = "Date",
y = "Number of Consultations",
color = "Condition"
) +
ylim(0, NA)

source(here::here("lib", "functions", "graph_func.R"))
plot1_conditions <- plot_pharmacy_first_conditions(df_measures)

6 changes: 0 additions & 6 deletions project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ expectations:
population_size: 1000

actions:
generate_dataset:
run: ehrql:v1 generate-dataset analysis/dataset_definition.py --output output/dataset.csv.gz
outputs:
highly_sensitive:
dataset: output/dataset.csv.gz

generate_pf_measures:
run: >
ehrql:v1 generate-measures analysis/report_measures.py
Expand Down

0 comments on commit 988bb1f

Please sign in to comment.