makeFile.R 940 Bytes
Newer Older
Ben Anderson's avatar
Ben Anderson committed
1
2
makeReport <- function(f){
  # default = html
Ben Anderson's avatar
Ben Anderson committed
3
  rmarkdown::render(input = paste0(here::here("itsTheCatsStupid", f), ".Rmd"),
Ben Anderson's avatar
Ben Anderson committed
4
5
6
7
8
9
10
11
12
                    params = list(title = title,
                                  subtitle = subtitle,
                                  authors = authors),
                    output_file = paste0(here::here("docs/"), f, ".html")
  )
}

# >> run report ----
rmdFile <- "itsTheCatsStupid" # not the full path
Ben Anderson's avatar
Ben Anderson committed
13
title = "#backOfaFagPacket: Its the Cats, stupid"
Ben Anderson's avatar
Ben Anderson committed
14
15
16
subtitle = "Does cat ownership correlate with home energy demand?"
authors = "Ben Anderson"

Ben Anderson's avatar
Ben Anderson committed
17
18
19
20
21
22
23
# load the postcode data here (slow)
dp <- "~/Dropbox/data/"
postcodes_dt <- data.table::fread(paste0(dp, "UK_postcodes/PCD_OA_LSOA_MSOA_LAD_AUG20_UK_LU.csv.gz"))
postcodes_dt[, pcd_sector := tstrsplit(pcds, " ", keep = c(1))]
lsoa_DT <- postcodes_dt[, .(nPostcodes = .N), keyby = .(pcd_sector, lsoa11cd, ladnm, ladnmw)]

# re-run report here
Ben Anderson's avatar
Ben Anderson committed
24
makeReport(rmdFile)