Skip to content

Commit

Permalink
update report
Browse files Browse the repository at this point in the history
  • Loading branch information
emprestige committed Feb 13, 2024
1 parent 2ef3a48 commit edd1324
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
30 changes: 30 additions & 0 deletions analysis/report.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
library("tidyverse")
library("here")
library("arrow")
library("ggplot2")
library("data.table")

## create output directories ----
fs::dir_create(here("analysis"))

#define study start date and study end date
source(here("analysis", "design", "design.R"))
args <- commandArgs(trailingOnly = TRUE)
study_start_date <- as.Date(as.numeric(study_dates[args[2]]), format = "%Y-%m-%d", origin = "1970-01-01")
study_end_date <- as.Date(as.numeric(study_dates[args[3]]), format = "%Y-%m-%d", origin = "1970-01-01")

df_input <- read_feather(
here::here("output", paste0("input_processed_", args[[1]], "_",
year(study_start_date), "_", year(study_end_date), ".arrow")))

lab <- ifelse(args[1] == "infants", "Age (Months)",
ifelse(args[1] == "infants_subgroup", "Age (Months)", "Age (Years)"))

plot_age <- ggplot(data = df_input, aes(age, frequency(age))) + geom_col(width = 0.9) +
xlab(lab) + ylab("Frequency")

ggsave(
plot = plot_age,
filename = paste0("descriptive_", args[[1]], "_", year(study_start_date),
"_", year(study_end_date), ".png"), path = here::here("output"),
)

This file was deleted.

This file was deleted.

9 changes: 8 additions & 1 deletion project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ actions:
outputs:
highly_sensitive:
cohort: output/input_processed_older_adults_2016_2017.arrow


describe_dataset_older_adults_s1:
run: r:latest analysis/report.R older_adults season1_start_date season1_end_date
needs: [process_dataset_older_adults_s1]
outputs:
moderately_sensitive:
cohort: output/descriptive_older_adults_2016_2017.png

generate_dataset_adults_s1:
run: >
ehrql:v1 generate-dataset analysis/dataset_definition.py
Expand Down

0 comments on commit edd1324

Please sign in to comment.