-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile_finalish
More file actions
74 lines (54 loc) · 2.21 KB
/
Makefile_finalish
File metadata and controls
74 lines (54 loc) · 2.21 KB
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
# Prepare annual baby name data report.
# Assumes:
# * the user is connected to the internet
# * has R installed in their PATH
# * has rmarkdown package installed
RAW = data/raw
print-% :
@echo "$*=$($*)"
START = 1900
END = 2015
YEARS=$(shell seq $(START) $(END))
YOB=$(addprefix $(RAW)/yob,$(YEARS))
YOBTXT=$(addsuffix .txt,$(YOB))
# Get Social Security name data
# Depends on: website data at https://www.ssa.gov/oact/babynames/names.zip
# Produces: slew of files named yob????.txt and a pdf file
$(YOBTXT) :
curl -Lo data/raw/names.zip https://www.ssa.gov/oact/babynames/names.zip
unzip -u -d data/raw/ data/raw/names.zip
# Concatenate the annual baby name data
# Depends on: $(RAW)/yob????.txt files
# code/concatenate_files.R
# Produces: data/processed/all_names.csv
data/processed/all_names.csv : code/concatenate_files.R $(YOBTXT)
R -e "source('code/concatenate_files.R')"
# Fills in missing data from annual survivorship data
# Depends on: $(RAW)/alive_2016_per_100k.csv
# code/interpolate_mortality.R
# Produces: data/processed/alive_2016_annual.csv
data/processed/alive_2016_annual.csv : code/interpolate_mortality.R $(RAW)/alive_2016_per_100k.csv
R -e "source('code/interpolate_mortality.R')"
# Generate counts of total and living people with each name
# Depends on: data/processed/alive_2016_annual.csv
# data/processed/all_names.csv
# code/get_total_and_living_name_counts.R
# Produces: data/processed/total_and_living_name_counts.csv
data/processed/total_and_living_name_counts.csv : code/get_total_and_living_name_counts.R data/processed/alive_2016_annual.csv data/processed/all_names.csv
R -e "source('code/get_total_and_living_name_counts.R')"
# Renders an Rmarkdown file that creates various plots and
# provides an entertaining color commentary
# Depends on: data/processed/total_and_living_name_counts.csv
# code/plot_functions.R
# Produces: family_report.html
family_report.html : family_report.Rmd\
code/plot_functions.R\
data/processed/total_and_living_name_counts.csv
R -e "library(rmarkdown); render('family_report.Rmd')"
.PHONY: clean
clean :
rm -f $(RAW)/*txt
rm -f $(RAW)/*pdf
rm -f $(RAW)/*zip
rm -f data/processed/*.csv
rm -f family_report.html