This repository has been archived by the owner on Jan 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathUPDATE.R
86 lines (58 loc) · 2.41 KB
/
UPDATE.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
setwd(dirname(rstudioapi::getActiveDocumentContext()$path))
library(tidyverse)
library(survey)
library(MEPS)
library(haven)
library(htmltools)
source("../r/functions.R")
source("dictionaries.R")
source("functions_run.R")
apps <- c("hc_use", "hc_care", "hc_ins", "hc_cond_icd10", "hc_pmed") #"hc_cond"
# Year (or years) that needs to be run
year_list <- 2018:2017
hc_year <- max(year_list)
# Set local directory for storing PUFs
# mydir = "/Users/emilymitchell/Desktop/MEPS"
mydir = "C:/MEPS"
# Optional: rename existing folder to QC code on previous years ---------------
# # still working on this part...
# for(year in year_list) { print(year)
# for(app in apps) {
# existing_folder = str_glue("data_tables/{app}/{year}")
# if(!existing_folder %in%
# list.files(str_glue("data_tables/{app}"), full.names = T)) {
# next
# }
# folder_copy = str_glue("data_tables/{app}/{year} - orig")
# dir.create(folder_copy)
# files <- list.files(existing_folder, full.names = T)
# file.copy(from = files, to = folder_copy)
# unlink(existing_folder, recursive = T)
# }
# }
# Create tables for new data year ---------------------------------------------
## !! For hc_cond icd10 versions (2016, 2017), need to build tables on secure
## !! LAN, since CCSR codes are not on PUFs
# Create new tables for data year -- takes about 3 hours
source("run_ins.R") # ~ 4 min
source("run_pmed.R") # ~ 2 min
source("run_care.R") # ~ 21 min
source("run_cond.R") # ~ 20 min.
source("run_use.R") # ~ 1 hr
# QC tables for new year -- need to update for hc_cond_icd10 to include more years
log_file <- "update_files/update_log.txt"
source("check_UPDATE.R")
## STOP!! CHECK LOG (update_files/update_log.txt) before proceeding
## Transfer hc_cond_icd10 tables here before formatting
# Format tables and create HTML / JSON files ----------------------------------
# Format tables to include in formatted_tables folder
# totPOP for 'Any event' is updated -- old version was including all people, including those with no events
source("tables_format.R")
# Update MASTER datasets
source("../r/Update_master.R")
# Run RtoHTML to update web pages with new year
source("../r/RtoHTML.R", chdir = T)
# Run RtoJSON to update JSON data with new year
write_data = F
write_notes = TRUE
source("../r/RtoJSON.R", chdir = T)