-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Summary table create r table format #116
base: development
Are you sure you want to change the base?
Conversation
…ory and hence...... Comment out setwd row 21 Change lp_path row 24 to my own working area - this change just for me and ooooops, left an old bit of copy and paste below.
…r that year the markdown crashes - have only hardcoded as temp measure as I think James was looking into a function for this issue/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
I've made lots of suggestions, but nothing major 👍
I did notice a mix of pipes - I think |>
is preferred now, so if unless there's something I missed where you're using a special ability of %>%
could you swap them out to make it consistent please?
title: '' | ||
output: | ||
word_document: | ||
reference_docx: "//conf/LIST_analytics/West Hub/02 - Scaled Up Work/RMarkdown/Locality Profiles/Summary Table/ST_ref_doc.docx" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reference_docx: "//conf/LIST_analytics/West Hub/02 - Scaled Up Work/RMarkdown/Locality Profiles/Summary Table/ST_ref_doc.docx" | |
reference_docx: "/conf/LIST_analytics/West Hub/02 - Scaled Up Work/RMarkdown/Locality Profiles/Summary Table/ST_ref_doc.docx" |
word_document: | ||
reference_docx: "//conf/LIST_analytics/West Hub/02 - Scaled Up Work/RMarkdown/Locality Profiles/Summary Table/ST_ref_doc.docx" | ||
--- | ||
; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think this is a typo?
; |
# LOCALITY <- "Whalsay and Skerries" | ||
# LOCALITY <- "Inverclyde East" | ||
|
||
# setwd("~/list-localities-profiles/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't ever need this?
# setwd("~/list-localities-profiles/") |
## Project file path | ||
lp_path <- "/conf/LIST_analytics/West Hub/02 - Scaled Up Work/RMarkdown/Locality Profiles/" | ||
|
||
# Source in global functions/themes script | ||
source("./Master RMarkdown Document & Render Code/Global Script.R") | ||
|
||
# # demographics | ||
source("./Demographics/1. Demographics - Population.R") | ||
source("./Demographics/2. Demographics - SIMD.R") | ||
# | ||
# # housing | ||
source("./Households/Households Code.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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these will need to be removed or commented out. I guess they were/are used for testing but we don't want them added uncommented?
Is sourcing all the scripts here the best way to test the summary table?
library(officer) | ||
library(officedown) | ||
|
||
# detach(package:tidylog, unload = TRUE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# detach(package:tidylog, unload = TRUE) |
color(part = "header", color = "white") %>% | ||
bg(part = "header", bg = "#3F3685") %>% | ||
bg(j = 1:3, part = "body", bg = "grey90") |> | ||
# width(j = 1, width = "22em") |> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# width(j = 1, width = "22em") |> |
scot_values <- c(scot_alcohol_hosp, scot_alcohol_deaths, scot_drug_hosp, scot_bowel_screening) | ||
|
||
|
||
lifestyle_values <-data.frame(indicators, datatype, time, loc_values, other_loc_values, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lifestyle_values <-data.frame(indicators, datatype, time, loc_values, other_loc_values, | |
lifestyle_values <- tibble(indicators, datatype, time, loc_values, other_loc_values, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another random observation (that I looked up) - tibble preserves all of the variable types whereas in old versions of r data.frame may convert strings into factors.
UC_values <-data.frame(indicators, datatype, time, loc_values, other_loc_values, | ||
hscp_values, scot_values) | ||
|
||
colnames(UC_values) <- headings | ||
|
||
UC_table <- flextable(UC_values) %>% | ||
bold(part = "header") %>% | ||
bold(j = 1, bold = TRUE, part = "body") %>% | ||
fontsize(part = "header", size = 12) %>% | ||
font(part = "body", fontname = "Arial") |> | ||
font(part = "header", fontname = "Arial") |> | ||
color(part = "header", color = "white") %>% | ||
bg(part = "header", bg = "#3F3685") %>% | ||
bg(j = 1:3, part = "body", bg = "grey90") |> | ||
# width(j = 1, width = "22em") |> | ||
border(border = fp_border(color = "white", width = 1), part = "body") |> | ||
set_table_properties(layout = "autofit") | ||
|
||
UC_table |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double check that UC_values
and/or UC_table
isn't used elsewhere before applying this suggestion.
UC_values <-data.frame(indicators, datatype, time, loc_values, other_loc_values, | |
hscp_values, scot_values) | |
colnames(UC_values) <- headings | |
UC_table <- flextable(UC_values) %>% | |
bold(part = "header") %>% | |
bold(j = 1, bold = TRUE, part = "body") %>% | |
fontsize(part = "header", size = 12) %>% | |
font(part = "body", fontname = "Arial") |> | |
font(part = "header", fontname = "Arial") |> | |
color(part = "header", color = "white") %>% | |
bg(part = "header", bg = "#3F3685") %>% | |
bg(j = 1:3, part = "body", bg = "grey90") |> | |
# width(j = 1, width = "22em") |> | |
border(border = fp_border(color = "white", width = 1), part = "body") |> | |
set_table_properties(layout = "autofit") | |
UC_table | |
uc_values <- tibble(indicators, datatype, time, loc_values, other_loc_values, | |
hscp_values, scot_values) | |
colnames(uc_values) <- headings | |
UC_table <- flextable(uc_values) %>% | |
bold(part = "header") %>% | |
bold(j = 1, bold = TRUE, part = "body") %>% | |
fontsize(part = "header", size = 12) %>% | |
font(part = "body", fontname = "Arial") |> | |
font(part = "header", fontname = "Arial") |> | |
color(part = "header", color = "white") %>% | |
bg(part = "header", bg = "#3F3685") %>% | |
bg(j = 1:3, part = "body", bg = "grey90") |> | |
border(border = fp_border(color = "white", width = 1), part = "body") |> | |
set_table_properties(layout = "autofit") | |
uc_table |
UC_MH_values <-data.frame(indicators, datatype, time, loc_values, other_loc_values, | ||
hscp_values, scot_values) | ||
|
||
colnames(UC_MH_values) <- headings | ||
|
||
UC_MH_table <- flextable(UC_MH_values) %>% | ||
bold(part = "header") %>% | ||
bold(j = 1, bold = TRUE, part = "body") %>% | ||
fontsize(part = "header", size = 12) %>% | ||
font(part = "body", fontname = "Arial") |> | ||
font(part = "header", fontname = "Arial") |> | ||
color(part = "header", color = "white") %>% | ||
bg(part = "header", bg = "#3F3685") %>% | ||
bg(j = 1:3, part = "body", bg = "grey90") |> | ||
# width(j = 1, width = "22em") |> | ||
border(border = fp_border(color = "white", width = 1), part = "body") |> | ||
set_table_properties(layout = "autofit") | ||
|
||
UC_MH_table | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UC_MH_values <-data.frame(indicators, datatype, time, loc_values, other_loc_values, | |
hscp_values, scot_values) | |
colnames(UC_MH_values) <- headings | |
UC_MH_table <- flextable(UC_MH_values) %>% | |
bold(part = "header") %>% | |
bold(j = 1, bold = TRUE, part = "body") %>% | |
fontsize(part = "header", size = 12) %>% | |
font(part = "body", fontname = "Arial") |> | |
font(part = "header", fontname = "Arial") |> | |
color(part = "header", color = "white") %>% | |
bg(part = "header", bg = "#3F3685") %>% | |
bg(j = 1:3, part = "body", bg = "grey90") |> | |
# width(j = 1, width = "22em") |> | |
border(border = fp_border(color = "white", width = 1), part = "body") |> | |
set_table_properties(layout = "autofit") | |
UC_MH_table | |
uc_mh_values <- tibble(indicators, datatype, time, loc_values, other_loc_values, | |
hscp_values, scot_values) | |
colnames(uc_mh_values) <- headings | |
uc_mh_table <- flextable(uc_mh_values) %>% | |
bold(part = "header") %>% | |
bold(j = 1, bold = TRUE, part = "body") %>% | |
fontsize(part = "header", size = 12) %>% | |
font(part = "body", fontname = "Arial") |> | |
font(part = "header", fontname = "Arial") |> | |
color(part = "header", color = "white") %>% | |
bg(part = "header", bg = "#3F3685") %>% | |
bg(j = 1:3, part = "body", bg = "grey90") |> | |
border(border = fp_border(color = "white", width = 1), part = "body") |> | |
set_table_properties(layout = "autofit") | |
uc_mh_table |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this file should have been committed. We can add HTML files to the .gitignore
so git ignores them in the future but can you delete this please?
@@ -34,15 +34,15 @@ library(reshape2) | |||
# LOCALITY <- "Ayr North and Former Coalfield Communities" | |||
# LOCALITY <- "Whalsay and Skerries" | |||
# LOCALITY <- "North Perthshire" | |||
|
|||
#LOCALITY <- "Inverclyde East" | |||
# Set date limit for financial year | |||
# Unless we're in Q4 use the previous FY as the max | |||
max_fy <- ifelse( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether I've commented on this before hmmmmmm. Would it be better having the max_fy as a function in Global?
Created new R Markdown for flextable summary table