diff --git a/analysis/dataset_definition.py b/analysis/dataset_definition.py deleted file mode 100644 index 18824f6..0000000 --- a/analysis/dataset_definition.py +++ /dev/null @@ -1,14 +0,0 @@ -from ehrql import create_dataset -from ehrql.tables.tpp import patients, practice_registrations - -dataset = create_dataset() - -index_date = "2020-03-31" - -has_registration = practice_registrations.for_patient_on( - index_date -).exists_for_patient() - -dataset.define_population(has_registration) - -dataset.sex = patients.sex diff --git a/analysis/stata.do b/analysis/stata.do deleted file mode 100644 index 0983157..0000000 --- a/analysis/stata.do +++ /dev/null @@ -1 +0,0 @@ -capture noisily import delimited ./output/output/dataset.csv, clear diff --git a/lib/functions/function_plot_measures.R b/lib/functions/function_plot_measures.R new file mode 100644 index 0000000..01bec02 --- /dev/null +++ b/lib/functions/function_plot_measures.R @@ -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 +} diff --git a/lib/functions/graph_func.R b/lib/functions/graph_func.R deleted file mode 100644 index e12a73d..0000000 --- a/lib/functions/graph_func.R +++ /dev/null @@ -1,18 +0,0 @@ -plot_pharmacy_first_conditions <- function(data, -title = "Number of Consultations for each Pharmacy First Clinical Condition per month", - x_label = "Date", - y_label = "Number of Consultations", - y_min = 0) { - 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") + - ylim(y_min, NA) + # Setting the minimum y-value - theme_minimal() # Applying the minimal theme -} diff --git a/lib/functions/visualise_data.R b/lib/functions/sketch.R similarity index 51% rename from lib/functions/visualise_data.R rename to lib/functions/sketch.R index 2d0b2fe..d4a3725 100644 --- a/lib/functions/visualise_data.R +++ b/lib/functions/sketch.R @@ -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) - \ No newline at end of file diff --git a/project.yaml b/project.yaml index 2cc1508..d7250b9 100644 --- a/project.yaml +++ b/project.yaml @@ -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