From fbc81b5f0850e54b97363560545b3570ca42eb42 Mon Sep 17 00:00:00 2001 From: James McMahon Date: Mon, 25 Mar 2024 15:32:48 +0000 Subject: [PATCH 1/3] Clean file path for map and throw error if it doesn't exist --- .../Locality Profiles Render Code.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Master RMarkdown Document & Render Code/Locality Profiles Render Code.R b/Master RMarkdown Document & Render Code/Locality Profiles Render Code.R index ca46529..32ea445 100755 --- a/Master RMarkdown Document & Render Code/Locality Profiles Render Code.R +++ b/Master RMarkdown Document & Render Code/Locality Profiles Render Code.R @@ -44,7 +44,9 @@ locality_list <- lookup %>% # 1. HSCP Services Map -map <- glue::glue(lp_path,"Master RMarkdown Document & Render Code/Output/maps","/",HSCP,".png") +map <- paste0(lp_path, "Master RMarkdown Document & Render Code/Output/maps/", HSCP, ".png") + +stopifnot(file.exists(map)) # Error if the file path doesn't exist. # 2. Loop through each locality to create the main body of the profiles and the summary table for (LOCALITY in locality_list) { From 35c6cccd3a255abb1f384f47689ef98beefa838f Mon Sep 17 00:00:00 2001 From: James McMahon Date: Mon, 25 Mar 2024 15:33:23 +0000 Subject: [PATCH 2/3] Use `knitr::include_graphics` --- .../Locality_Profiles_Master_Markdown.Rmd | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Master RMarkdown Document & Render Code/Locality_Profiles_Master_Markdown.Rmd b/Master RMarkdown Document & Render Code/Locality_Profiles_Master_Markdown.Rmd index 4717ad7..3d11375 100755 --- a/Master RMarkdown Document & Render Code/Locality_Profiles_Master_Markdown.Rmd +++ b/Master RMarkdown Document & Render Code/Locality_Profiles_Master_Markdown.Rmd @@ -203,8 +203,7 @@ x <- x + 1 \newline ```{r echo = FALSE} -#knitr::include_graphics(map) -htmltools::img(map) +knitr::include_graphics(map, rel_path = FALSE) x <- x + 1 ``` From 37579beab0d04a86cab381db5554d33aad2597c2 Mon Sep 17 00:00:00 2001 From: James McMahon Date: Mon, 25 Mar 2024 15:39:20 +0000 Subject: [PATCH 3/3] Style code --- .../Locality Profiles Render Code.R | 18 +++++++++--------- .../Locality_Profiles_Master_Markdown.Rmd | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Master RMarkdown Document & Render Code/Locality Profiles Render Code.R b/Master RMarkdown Document & Render Code/Locality Profiles Render Code.R index 32ea445..e421528 100755 --- a/Master RMarkdown Document & Render Code/Locality Profiles Render Code.R +++ b/Master RMarkdown Document & Render Code/Locality Profiles Render Code.R @@ -51,26 +51,26 @@ stopifnot(file.exists(map)) # Error if the file path doesn't exist. # 2. Loop through each locality to create the main body of the profiles and the summary table for (LOCALITY in locality_list) { ## 2a) Source in all the scripts for a given LOCALITY - + # demographics source("Demographics/1. Demographics - Population.R") source("./Demographics/2. Demographics - SIMD.R") - + # housing source("./Households/Households Code.R") - + # services source("./Services/2. Services data manipulation & table.R") - + # general health source("./General Health/3. General Health Outputs.R") - + # lifestyle & risk factors source("./Lifestyle & Risk Factors/2. Lifestyle & Risk Factors Outputs.R") - + # unscheduled care source("./Unscheduled Care/2. Unscheduled Care outputs.R") - + # appendices source("./Master RMarkdown Document & Render Code/Tables for Appendix.R") @@ -78,9 +78,9 @@ for (LOCALITY in locality_list) { detach(package:tidylog, unload = TRUE) ## 2b) Create the main body of the profiles - + rmarkdown::render("./Master RMarkdown Document & Render Code/Locality_Profiles_Master_Markdown.Rmd", - output_file = paste0(LOCALITY, " - Locality Profile.docx"), + output_file = paste0(LOCALITY, " - Locality Profile.docx"), output_dir = paste0(lp_path, "Master RMarkdown Document & Render Code/Output/") ) diff --git a/Master RMarkdown Document & Render Code/Locality_Profiles_Master_Markdown.Rmd b/Master RMarkdown Document & Render Code/Locality_Profiles_Master_Markdown.Rmd index 3d11375..47238e9 100755 --- a/Master RMarkdown Document & Render Code/Locality_Profiles_Master_Markdown.Rmd +++ b/Master RMarkdown Document & Render Code/Locality_Profiles_Master_Markdown.Rmd @@ -26,21 +26,21 @@ y <- 1 # tables # # demographics # source("Demographics/Scripts/1. Demographics - Population.R") # source("Demographics/Scripts/2. Demographics - SIMD.R") -# +# # # housing # source("Households/Scripts/Households Code.R") -# +# # # services # source("Services/Scripts/2. Services data manipulation & table.R") # # services map (uncomment this when testing out individual localities) # # source("Services/Scripts/3. Service HSCP map.R") -# +# # # general health # source("General Health/Scripts/3. General Health Outputs.R") -# +# # # lifestyle & risk factors # source("Lifestyle & Risk Factors/Scripts/2. Lifestyle & Risk Factors Outputs.R") -# +# # # unscheduled care # source("Unscheduled Care/Scripts/2. Unscheduled Care outputs.R") #