File size: 1,084 Bytes
c868958
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
## Initialize workspace.
# Clear workspace.
rm(list = ls(all = TRUE))

# Set working directory to abp_replication directory.
setwd("~/Downloads/hbg_replication")

## Prepare output directory and main output files.
# If an output directory does not exist, create the directory.
if (!file.exists("output")) {
	dir.create("output")
}

# Create a log file for console output.
hbg_log <- file("output/hbg_log.txt", open = "wt")

# Echo and sink console log to psv_log file.
sink(hbg_log, append = TRUE)
sink(hbg_log, append = TRUE, type = "message")

## Replicate files and produce main output.
# Run abp_replication_code.R script, storing run-time statistics.
run_time <- system.time({source("scripts/hbg_cleaning.R", echo = TRUE, 
								max.deparse.length = 10000)
						 source("scripts/hbg_analysis.R", echo = TRUE,
						 	    max.deparse.length = 10000)})

# Close main output sink.
sink()
sink(type = "message")

## Sink run-time statistics to a run_time output file.
run_time_file <- file("output/run_time", open = "wt")
sink(run_time_file, append = TRUE)
print(run_time)
sink()