generated from opensafely/research-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from opensafely/milanwiedemann/improve-viz
Improve visualisations and update report
- Loading branch information
Showing
5 changed files
with
334 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#' Tidy measures data | ||
#' | ||
#' Creates a tidier dataframe of measures data. | ||
#' The measures must be named in a spedific way for this function to work properly. | ||
#' | ||
#' @param data A dataframe containing output from the OpenSAFELY measures framework | ||
#' @param pf_measures_name_dict List, specifying the dict of measure names. | ||
#' This information will be pulled from the original measure name. | ||
#' @param pf_measures_name_mapping List, specifying the mapping of measures to groups. | ||
#' This information will be pulled from the original measure name. | ||
#' @param pf_measures_groupby_dict List, specifying the dict of groupby/breakdown names. | ||
#' This information will be pulled from the original measure name. | ||
#' | ||
#' @return A dataframe | ||
tidy_measures <- function(data, pf_measures_name_dict, pf_measures_name_mapping, pf_measures_groupby_dict) { | ||
data_tmp <- data %>% | ||
separate(measure, into = c("summary_stat_measure", "group_by"), sep = "_by_") %>% | ||
separate(summary_stat_measure, into = c("summary_stat", "measure"), sep = "_", extra = "merge") | ||
|
||
data_tmp <- data_tmp %>% | ||
mutate( | ||
measure_desc = recode(factor(measure), !!!pf_measures_name_mapping), | ||
measure = recode(factor(measure), !!!pf_measures_name_dict), | ||
group_by = recode(factor(group_by), !!!pf_measures_groupby_dict) | ||
) | ||
|
||
data_tmp | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
library/ | ||
local/ | ||
cellar/ | ||
lock/ | ||
python/ | ||
sandbox/ | ||
staging/ |
Oops, something went wrong.