Skip to content
Snippets Groups Projects
makeFile.R 983 B
Newer Older
Ben Anderson's avatar
Ben Anderson committed
makeReport <- function(f){
  # default = html
Ben Anderson's avatar
Ben Anderson committed
  rmarkdown::render(input = paste0(here::here("itsTheCatsStupid", f), ".Rmd"),
Ben Anderson's avatar
Ben Anderson committed
                    params = list(title = title,
                                  subtitle = subtitle,
                                  authors = authors),
                    output_file = paste0(here::here("docs/"), f, ".html")
  )
}

# Run report ----

#> set data path ----
dp <- "~/Dropbox/data/"

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

#> load the postcode data here (slow)
Ben Anderson's avatar
Ben Anderson committed
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))]
Ben Anderson's avatar
Ben Anderson committed
lsoa_DT <- postcodes_dt[, .(nPostcodes = .N), keyby = .(lsoa11cd, pcd_sector, ladnm, ladnmw)]
Ben Anderson's avatar
Ben Anderson committed

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