Skip to content

Commit 88e06e6

Browse files
Restructure and rename plotting fun
1 parent a061dff commit 88e06e6

File tree

3 files changed

+44
-28
lines changed

3 files changed

+44
-28
lines changed
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-

0 commit comments

Comments
 (0)