|
@@ -1,33 +1,8 @@
|
|
1
|
+# Process csv data into an RData file to be loaded by the shiny application
|
1
|
2
|
library(readr)
|
2
|
|
-library(ggplot2)
|
3
|
3
|
library(dplyr)
|
4
|
|
-library(igraph)
|
5
|
4
|
education_travel <- read_csv("travel-education.csv")
|
6
|
5
|
work_travel <- read_csv("travel-work.csv")
|
7
|
|
-length(unique(education_travel$SA2_name_usual_residence_address))
|
8
|
|
-length(unique(education_travel$SA2_name_educational_address))
|
9
|
|
-length(unique(work_travel$SA2_name_usual_residence_address))
|
10
|
|
-length(unique(work_travel$SA2_name_workplace_address))
|
11
|
|
-
|
12
|
|
-ggplot(work_travel, aes(x = SA2_code_usual_residence_address,
|
13
|
|
- y = SA2_code_workplace_address,
|
14
|
|
- fill = Total)) +
|
15
|
|
- geom_tile()
|
16
|
|
-
|
17
|
|
-g2 <- graph( edges=c(4,9, 9,6, 6, 4, 1,2, 5,6, 9,5, 1,4, 1,5, 2,6, 3,3, 6,6), n=10 )
|
18
|
|
-plot(g2)
|
19
|
|
-
|
20
|
|
-tg <- make_empty_graph()
|
21
|
|
-
|
22
|
|
-work_travel %>% filter(Total > 100) %>% select(SA2_name_usual_residence_address, SA2_name_workplace_address) %>%
|
23
|
|
- as.matrix %>% t %>% as.vector -> elist
|
24
|
|
-
|
25
|
|
-locgraph <- graph(edges = elist)
|
26
|
|
-
|
27
|
|
-# plot(locgraph, label = NA)
|
28
|
|
-
|
29
|
|
-sg <- decompose(locgraph, mode="weak")
|
30
|
|
-
|
31
|
6
|
|
32
|
7
|
work_travel %>% select(
|
33
|
8
|
res_code = SA2_code_usual_residence_address,
|
|
@@ -144,8 +119,6 @@ edu_simp %>% group_by(edu_code, edu_name, edu_east, edu_north) %>%
|
144
|
119
|
|
145
|
120
|
tencols <- c("#f85654", "#e31a1c", "#1f78b4", "#6a3d9a", "#b2df8a",
|
146
|
121
|
"#33a02c", "#fdbf6f", "#ff7f00", "#cab2d6", "#af8ac1")
|
147
|
|
-tencols[which.max(work_from[1, 5:14])]
|
148
|
|
-
|
149
|
122
|
|
150
|
123
|
work_from$MAX <- work_from %>% select(private:home) %>% as.matrix() %>%
|
151
|
124
|
apply(1, function(x) {
|
|
@@ -174,4 +147,3 @@ edu_simp$MAX <- edu_simp %>% select(drive:home) %>% as.matrix() %>%
|
174
|
147
|
})
|
175
|
148
|
|
176
|
149
|
save(work_simp, work_to, work_from, edu_simp, edu_to, edu_from, tencols, file="viz/datasets.RData")
|
177
|
|
-
|