-
Notifications
You must be signed in to change notification settings - Fork 0
/
00_source_me.R
65 lines (54 loc) · 3.29 KB
/
00_source_me.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Copyright 2022 Province of British Columbia
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and limitations under the License.
#' TO DO before sourcing this file:
#'
#' Get an RTRA account. (application form in directory `SAS`, send to Naomi)
#' upload the 2 .SAS files in directory `SAS` to https://www75.statcan.gc.ca/eft-tef/en/operations (To StatCan).
#' grab a coffee...
#' download the 2 resulting csv files (From StatCan) and place in directory "data/current".
#' Click the Git button and pull to make sure the script is the most recent version.
#' then source this file.
#' Note that Jan 2026 the SAS files will need to be updated.
#' 1. The .csv files starting with `dont_delete` will need to be deleted.
#' 2. December's .csv files will need to be copied from old inputs to current inputs and prepended with `dont_delete`.
#' 3. the SAS files will need to be updated regarding the dates.
#' Output found in directory out/current.
# check to make sure directory structure exists------------------------------
if (!dir.exists("data")) {dir.create("data")}
if (!dir.exists(file.path("data","current"))) {dir.create(file.path("data","current"))}
if (!dir.exists(file.path("data","old"))) {dir.create(file.path("data","old"))}
if (!dir.exists("out")) {dir.create("out")}
if (!dir.exists(file.path("out","current"))) {dir.create(file.path("out","current"))}
if (!dir.exists(file.path("out","old"))) {dir.create(file.path("out","old"))}
if (!dir.exists("temp")) {dir.create("temp")}
#are the required files where they are supposed to be?----------------
assertthat::assert_that(length(list.files(here::here("data","current"), pattern="ftptemp4digNAICS"))==2,
msg="2 files with the pattern ftptemp4digNAICS must be in folder data/current")
assertthat::assert_that(length(list.files(here::here("data","current"), pattern="lfsstat4digNAICS"))==2,
msg="2 files with the pattern lfsstat4digNAICS must be in folder data/current")
assertthat::assert_that(length(list.files(here::here("data"), pattern="mapping.xlsx"))==1,
msg="The file mapping.xlsx must be in folder data")
assertthat::assert_that(length(list.files(here::here("data"), pattern="template"))==1,
msg="The file template.xlsx must be in folder data")
#archive old output
filesstrings::file.move(here::here("out","current", list.files(here::here("out", "current"))),
here::here("out", "old"), overwrite = TRUE)
#create new output
source("01_process_data.R")
rmarkdown::render("02_dashboard.Rmd",
output_file = paste0("LFS_industry_profiles_",lubridate::today(),".html"),
output_dir = here::here("out","current"))
#archive input files--------
# filesstrings::file.move(here::here("data","current", list.files(here::here("data", "current"), pattern = "RTRA")),
# here::here("data", "old"), overwrite = TRUE)
#
#