Skip to content

Commit

Permalink
kicking of #14
Browse files Browse the repository at this point in the history
  • Loading branch information
andkov committed Aug 17, 2022
1 parent aad3911 commit 77239fb
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions scripts/templates/regions-and-distributions.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
rm(list = ls(all.names = TRUE)) # Clear the memory of variables from previous run. This is not called by knitr, because it's above the first chunk.
cat("\014") # Clear the console
# verify root location
cat("Working directory: ", getwd()) # Must be set to Project Directory
# Project Directory should be the root by default unless overwritten

# ---- load-packages -----------------------------------------------------------
# Choose to be greedy: load only what's needed
# Three ways, from least (1) to most(3) greedy:
# -- 1.Attach these packages so their functions don't need to be qualified: http://r-pkgs.had.co.nz/namespace.html#search-path
library(ggplot2) # graphs
library(forcats) # factors
library(stringr) # strings, but consider `stringi` as more general
library(lubridate) # dates
library(labelled) # labels
# -- 2.Import only certain functions of a package into the search path.
import::from("magrittr", "%>%")
# -- 3. Verify these packages are available on the machine, but their functions need to be qualified: http://r-pkgs.had.co.nz/namespace.html#search-path
requireNamespace("readr" )# data import/export
requireNamespace("readxl" )# data import/export
requireNamespace("tidyr" )# tidy data
requireNamespace("janitor" )# tidy data
requireNamespace("testit" )# for asserting conditions meet expected patterns.
requireNamespace("scales" )# formatting

# ---- load-sources ------------------------------------------------------------
base::source("./scripts/common-functions.R") # project-level

# ---- declare-globals ---------------------------------------------------------
# printed figures will go here when `quick_save("name",w=8,h=6)` is used:
prints_folder <- paste0("./analysis/regions-and-distributions/regions-and-distributions/prints/")
if (!fs::dir_exists(prints_folder)) { fs::dir_create(prints_folder) }

path_admin <- "./data-private/derived/ua-admin-map.rds" # product of ./manipulation/ellis-ua-admin.R
path_time <- "./data-private/derived/time_rada.csv" # product of ./manipulation/ellis-rada-hromada.R

# ---- declare-functions -------------------------------------------------------

# ---- load-data ---------------------------------------------------------------
ds_admin <- readr::read_rds(path_admin)
ds_time <- readr::read_csv(path_time)

# ---- inspect-data ------------------------------------------------------------


# ---- tweak-data --------------------------------------------------------------


# ---- table-1 -----------------------------------------------------------------


# ---- graph-1 -----------------------------------------------------------------


# ---- graph-2 -----------------------------------------------------------------

# ---- save-to-disk ------------------------------------------------------------

# ---- publish ------------------------------------------------------------
path <- "./analysis/regions-and-distributions/regions-and-distributions.Rmd" # connect with Rmd for publishing
rmarkdown::render(
input = path ,
output_format=c(
"html_document"
# "word_document"
# "pdf_document"
),
clean=TRUE
)

0 comments on commit 77239fb

Please sign in to comment.