From bcad947224d8def772be3c8e67c770eab5d0f00f Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 10 Sep 2023 07:50:28 +0000 Subject: [PATCH] Added note for reproducibility Brief explanation given to run the code if the audit is to be auditable --- audit-snippets.Rmd | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/audit-snippets.Rmd b/audit-snippets.Rmd index e966aaa..5d659d5 100644 --- a/audit-snippets.Rmd +++ b/audit-snippets.Rmd @@ -1,16 +1,22 @@ --- title: "Code Snippets Audit" -output: html_notebook +output: + html_document: + df_print: paged --- + + + + # collection of snippets for the data collection # Setup and calculations -```{r setup, include=FALSE, echo=FALSE} +```{r setup, include=TRUE, echo=TRUE} library(readr) library(ggplot2) library(dplyr) @@ -299,7 +305,7 @@ FinalIncluded <- nrow(HtnDataold[HtnDataold$Inclusion_Crit == 1, ]) # Flow Chart -```{r flowchart, include=TRUE, echo=FALSE, fig.cap="Case Selection for Kimberley Hypertension Audit of 2022 Patients"} +```{r flowchart, include=TRUE, echo=TRUE, fig.cap="Case Selection for Kimberley Hypertension Audit of 2022 Patients"} # Define ineligibles, all others defined before Ineligibles <- nrow(HtnDataold) - FinalIncluded @@ -341,7 +347,7 @@ ggflowchart( # Table of age categories -```{r tableofage, echo=FALSE, include=TRUE, warning=FALSE, fig.cap='Age Distribution of Patient Sample', fig.pos ='H', message=FALSE} +```{r tableofage, echo=TRUE, include=TRUE, warning=FALSE, fig.cap='Age Distribution of Patient Sample', fig.pos ='H', message=FALSE} library(kableExtra) # Summarise data AgeTable <- HtnData %>% @@ -366,7 +372,7 @@ kable(AgeTable, digits = 2, caption = "Age distribution of Patient Sample", alig # Converting variables to in text references -```{r calculatingstandards-results, echo=FALSE} +```{r calculatingstandards-results, echo=TRUE} OldSt1Text <- round(mean(as.numeric(HtnData$Old_Std_1_Met)) * 100, 1) OldSt2Text <- round(mean(as.numeric(HtnData$Old_Std_2_Met)) * 100, 1) @@ -378,7 +384,7 @@ OldASt2Text <- mean(as.numeric(HtnData$Old_audit_Std_2_Met)) * 100 # Bar graph comparing previous and current audit results -```{r bargraphStandardOld, echo=FALSE, include=TRUE, fig.cap="Comparison of Previous and Present Audit Based on Previous Standard"} +```{r bargraphStandardOld, echo=TRUE, include=TRUE, fig.cap="Comparison of Previous and Present Audit Based on Previous Standard"} # Unite the columns into one dataframe standards <- HtnData %>% select(Old_Std_1_Met, Old_Std_2_Met, Old_audit_Std_1_Met, Old_audit_Std_2_Met) %>% @@ -409,7 +415,7 @@ ggplot(standards, aes(x = Standard_No, y = Percentage, fill = Condition)) + # New standard Pie Chart -```{r newstandard1, echo=FALSE, include=TRUE, fig.cap = "Proportion Of Present Audit Adherence With Standard 1"} +```{r newstandard1, echo=TRUE, include=TRUE, fig.cap = "Proportion Of Present Audit Adherence With Standard 1"} generate_pie_chart <- function(data, column, title) { # Count TRUE and FALSE instances counts <- table(data[[column]]) @@ -453,7 +459,7 @@ print(newstandard1) # Baseline investigations -```{r AdherenceBaselineFull, echo=FALSE, include=TRUE, fig.cap="Adherence to Standard for Baseline Investigations"} +```{r AdherenceBaselineFull, echo=TRUE, include=TRUE, fig.cap="Adherence to Standard for Baseline Investigations"} columns_to_run <- c("HbA1c" = "HbA1c", "Lipid" = "Lipids", "U_E" = "U&Es", "Dip_Urine" = "Urine Dipstick", "ACR_Urine" = "Urine ACR") @@ -505,7 +511,7 @@ ggplot(adherence_inv_perc, aes(x = pretty_label, y = adherence, fill = color)) + # Other management bar graph -```{r OtherManagement, include=TRUE, echo=FALSE, fig.cap="Adherence of Remaining Criteria"} +```{r OtherManagement, include=TRUE, echo=TRUE, fig.cap="Adherence of Remaining Criteria"} # Calculate adherence counts_715 <- table(HtnData$c715_Check) @@ -542,7 +548,7 @@ print(p) # Standard 2 Pie chart -```{r newstandard2, echo=FALSE, include=TRUE, fig.cap="Proportion of Present Audit Adherence with Standard 2"} +```{r newstandard2, echo=TRUE, include=TRUE, fig.cap="Proportion of Present Audit Adherence with Standard 2"} generate_pie_chart <- function(data, column, title) { # Get proportions of true and false counts <- table(data[[column]]) @@ -585,7 +591,7 @@ print(newstandard1) # Follow up criteria -```{r followupfinal, include=TRUE, echo=FALSE, fig.cap="Adherence to Criteria for Followup"} +```{r followupfinal, include=TRUE, echo=TRUE, fig.cap="Adherence to Criteria for Followup"} # Calculate adherence to followup HtnData$initial_flwp <- (HtnData$c3_MO_RVW_LFSTL | HtnData$c2_4_WK_RVW_ACE) HtnData$complete_followup_adherence <- HtnData$initial_flwp & HtnData$c3_MO_FLWP_STBL_WITHNA & HtnData$c6_MO_BP @@ -631,7 +637,7 @@ ggplot(adherence_flwp_perc, aes(x = pretty_label, y = adherence, fill = pretty_l # More in text references for variables -```{r calculatingstandards-discussion, echo=FALSE} +```{r calculatingstandards-discussion, echo=TRUE} OldSt1Text <- round(mean(as.numeric(HtnData$Old_Std_1_Met)) * 100) OldSt2Text <- round(mean(as.numeric(HtnData$Old_Std_2_Met)) * 100) @@ -655,7 +661,7 @@ texturin <- round(sum(counts_urin["TRUE"]) /sum(counts_urin) * 100, 1) ## Action Plan -```{r actionplan, echo=FALSE, include=TRUE, message=FALSE, fig.pos ='H', fig.cap="Action Plan following 2023 Audit of Adherence to Kimberley Hypertension Guidelines"} +```{r actionplan, echo=TRUE, include=TRUE, message=FALSE, fig.pos ='H', fig.cap="Action Plan following 2023 Audit of Adherence to Kimberley Hypertension Guidelines"} library(readxl) library(kableExtra) @@ -674,4 +680,10 @@ kableExtra::kable(df, format = "latex", booktabs = TRUE, linesep = "\\addlinespa ``` +Copyright 2023 Liam Jones +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file