-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheducation_older_conversion.R
148 lines (128 loc) · 6.98 KB
/
education_older_conversion.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
temp_counts <- edu_state %>%
rename(`Group Population`=summary_est) %>%
filter(group == "Asian Alone") %>%
filter(estimate_type=="count") %>%
select(State,`Group Population`,topic_type, estimate) %>%
rename(`Asian Alone Total`=`Group Population`) %>%
mutate(topic_type= paste("Asian Alone",topic_type,sep = " ")) %>%
spread(topic_type,estimate)
temp_prop <- edu_state %>%
rename(`Group Population`=summary_est) %>%
filter(group == "Asian Alone") %>%
filter(estimate_type=="prop") %>%
select(State,topic_type, estimate) %>%
mutate(estimate = round(estimate *100,2)) %>%
mutate(topic_type= paste("Asian Alone Share ",topic_type,sep = "")) %>%
spread(topic_type,estimate)
temp_asian <- left_join(temp_counts,temp_prop)
rm(temp_counts,temp_prop)
temp_counts <- edu_state %>%
rename(`Group Population`=summary_est) %>%
filter(group == "NHPI Alone") %>%
filter(estimate_type=="count") %>%
select(State,`Group Population`,topic_type, estimate) %>%
rename(`NHPI Alone Total`=`Group Population`) %>%
mutate(topic_type= paste("NHPI Alone",topic_type,sep = " ")) %>%
spread(topic_type,estimate)
temp_prop <- edu_state %>%
rename(`Group Population`=summary_est) %>%
filter(group == "NHPI Alone") %>%
filter(estimate_type=="prop") %>%
select(State,topic_type, estimate) %>%
mutate(estimate = round(estimate *100,2)) %>%
mutate(topic_type= paste("NHPI Alone Share ",topic_type,sep = "")) %>%
spread(topic_type,estimate)
temp_nhpi <- left_join(temp_counts,temp_prop)
temp_final <- left_join(temp_asian,temp_nhpi)
temp_final %>% colnames()
temp_final %>% select(State, `Asian Alone Total`, `Asian Alone Less than HS`, `Asian Alone HS or GED`,
`Asian Alone Some College or AA`,`Asian Alone BA or higher`, `Asian Alone Share Less than HS`, `Asian Alone Share HS or GED`,`Asian Alone Share Some College or AA`,`Asian Alone Share BA or higher`,
`NHPI Alone Total`, `NHPI Alone Less than HS`, `NHPI Alone HS or GED`,
`NHPI Alone Some College or AA`,`NHPI Alone BA or higher`, `NHPI Alone Share Less than HS`, `NHPI Alone Share HS or GED`,`NHPI Alone Share Some College or AA`,`NHPI Alone Share BA or higher`) %>%
write_csv("old_quickstats/state_edu_all.csv",na="")
# COUNTY ------------------------------------------------------------------
temp_counts <- edu_county %>%
rename(`Group Population`=summary_est) %>%
filter(group == "Asian Alone") %>%
filter(estimate_type=="count") %>%
select(County,State,`Group Population`,topic_type, estimate) %>%
rename(`Asian Alone Total`=`Group Population`) %>%
mutate(topic_type= paste("Asian Alone",topic_type,sep = " ")) %>%
spread(topic_type,estimate)
temp_prop <- edu_county %>%
rename(`Group Population`=summary_est) %>%
filter(group == "Asian Alone") %>%
filter(estimate_type=="prop") %>%
select(County,State,topic_type, estimate) %>%
mutate(estimate = round(estimate *100,2)) %>%
mutate(topic_type= paste("Asian Alone Share ",topic_type,sep = "")) %>%
spread(topic_type,estimate)
temp_asian <- left_join(temp_counts,temp_prop)
rm(temp_counts,temp_prop)
temp_counts <- edu_county %>%
rename(`Group Population`=summary_est) %>%
filter(group == "NHPI Alone") %>%
filter(estimate_type=="count") %>%
select(County,State,`Group Population`,topic_type, estimate) %>%
rename(`NHPI Alone Total`=`Group Population`) %>%
mutate(topic_type= paste("NHPI Alone",topic_type,sep = " ")) %>%
spread(topic_type,estimate)
temp_prop <- edu_county %>%
rename(`Group Population`=summary_est) %>%
filter(group == "NHPI Alone") %>%
filter(estimate_type=="prop") %>%
select(County,State,topic_type, estimate) %>%
mutate(estimate = round(estimate *100,2)) %>%
mutate(topic_type= paste("NHPI Alone Share ",topic_type,sep = "")) %>%
spread(topic_type,estimate)
temp_nhpi <- left_join(temp_counts,temp_prop)
temp_final <- left_join(temp_asian,temp_nhpi)
temp_final %>% colnames()
temp_final %>% select(County,State, `Asian Alone Total`, `Asian Alone Less than HS`, `Asian Alone HS or GED`,
`Asian Alone Some College or AA`,`Asian Alone BA or higher`, `Asian Alone Share Less than HS`, `Asian Alone Share HS or GED`,`Asian Alone Share Some College or AA`,`Asian Alone Share BA or higher`,
`NHPI Alone Total`, `NHPI Alone Less than HS`, `NHPI Alone HS or GED`,
`NHPI Alone Some College or AA`,`NHPI Alone BA or higher`, `NHPI Alone Share Less than HS`, `NHPI Alone Share HS or GED`,`NHPI Alone Share Some College or AA`,`NHPI Alone Share BA or higher`) %>%
write_csv("old_quickstats/county_edu_all.csv",na="")
# DISTRICT ----------------------------------------------------------------
temp_counts <- edu_district %>%
rename(`Group Population`=summary_est) %>%
filter(group == "Asian Alone") %>%
filter(estimate_type=="count") %>%
select(District,State,`Group Population`,topic_type, estimate) %>%
rename(`Asian Alone Total`=`Group Population`) %>%
mutate(topic_type= paste("Asian Alone",topic_type,sep = " ")) %>%
spread(topic_type,estimate)
temp_prop <- edu_district %>%
rename(`Group Population`=summary_est) %>%
filter(group == "Asian Alone") %>%
filter(estimate_type=="prop") %>%
select(District,State,topic_type, estimate) %>%
mutate(estimate = round(estimate *100,2)) %>%
mutate(topic_type= paste("Asian Alone Share ",topic_type,sep = "")) %>%
spread(topic_type,estimate)
temp_asian <- left_join(temp_counts,temp_prop)
rm(temp_counts,temp_prop)
temp_counts <- edu_district %>%
rename(`Group Population`=summary_est) %>%
filter(group == "NHPI Alone") %>%
filter(estimate_type=="count") %>%
select(District,State,`Group Population`,topic_type, estimate) %>%
rename(`NHPI Alone Total`=`Group Population`) %>%
mutate(topic_type= paste("NHPI Alone",topic_type,sep = " ")) %>%
spread(topic_type,estimate)
temp_prop <- edu_district %>%
rename(`Group Population`=summary_est) %>%
filter(group == "NHPI Alone") %>%
filter(estimate_type=="prop") %>%
select(District,State,topic_type, estimate) %>%
mutate(estimate = round(estimate *100,2)) %>%
mutate(topic_type= paste("NHPI Alone Share ",topic_type,sep = "")) %>%
spread(topic_type,estimate)
temp_nhpi <- left_join(temp_counts,temp_prop)
temp_final <- left_join(temp_asian,temp_nhpi)
temp_final %>% colnames()
temp_final %>% select(District,State, `Asian Alone Total`, `Asian Alone Less than HS`, `Asian Alone HS or GED`,
`Asian Alone Some College or AA`,`Asian Alone BA or higher`, `Asian Alone Share Less than HS`, `Asian Alone Share HS or GED`,`Asian Alone Share Some College or AA`,`Asian Alone Share BA or higher`,
`NHPI Alone Total`, `NHPI Alone Less than HS`, `NHPI Alone HS or GED`,
`NHPI Alone Some College or AA`,`NHPI Alone BA or higher`, `NHPI Alone Share Less than HS`, `NHPI Alone Share HS or GED`,`NHPI Alone Share Some College or AA`,`NHPI Alone Share BA or higher`) %>%
write_csv("old_quickstats/district_edu_all.csv",na="")