Browse Source

Switch order of work at home and other

Petra Lamborn 3 years ago
parent
commit
0337e240cd
2 changed files with 16 additions and 16 deletions
  1. 13
    13
      scratch.R
  2. 3
    3
      viz/app.R

+ 13
- 13
scratch.R View File

@@ -46,8 +46,8 @@ work_travel %>% select(
46 46
   bus = Public_bus,
47 47
   train = Train,
48 48
   ferry = Ferry,
49
-  home = Work_at_home,
50 49
   other = Other,
50
+  home = Work_at_home,
51 51
   total = Total
52 52
 ) -> work_simp
53 53
 
@@ -65,8 +65,8 @@ work_simp %>%
65 65
     bus = sum(ifelse(bus < 0, 0, bus)),
66 66
     train = sum(ifelse(train < 0, 0, train)),
67 67
     ferry = sum(ifelse(ferry < 0, 0, ferry)),
68
-    home = sum(ifelse(home < 0, 0, home)),
69 68
     other = sum(ifelse(other < 0, 0, other)),
69
+    home = sum(ifelse(home < 0, 0, home)),
70 70
     total = sum(ifelse(total < 0, 0, total)), .groups="drop"
71 71
   ) -> work_from
72 72
     
@@ -85,8 +85,8 @@ work_simp %>%
85 85
     bus = sum(ifelse(bus < 0, 0, bus)),
86 86
     train = sum(ifelse(train < 0, 0, train)),
87 87
     ferry = sum(ifelse(ferry < 0, 0, ferry)),
88
-    home = sum(ifelse(home < 0, 0, home)),
89 88
     other = sum(ifelse(other < 0, 0, other)),
89
+    home = sum(ifelse(home < 0, 0, home)),
90 90
     total = sum(ifelse(total < 0, 0, total)), .groups="drop"
91 91
   ) -> work_to
92 92
 
@@ -107,8 +107,8 @@ edu_simp <- education_travel %>% select(
107 107
   pubbus = Public_bus,
108 108
   train = Train,
109 109
   ferry = Ferry,
110
-  home = Study_at_home,
111 110
   other = Other,
111
+  home = Study_at_home,
112 112
   total = Total
113 113
 )
114 114
 
@@ -122,8 +122,8 @@ edu_simp %>% group_by(res_code, res_name, res_east, res_north) %>%
122 122
     pubbus = sum(ifelse(pubbus < 0, 0, pubbus)),
123 123
     train = sum(ifelse(train < 0, 0, train)),
124 124
     ferry = sum(ifelse(ferry < 0, 0, ferry)),
125
-    home = sum(ifelse(home < 0, 0, home)),
126 125
     other = sum(ifelse(other < 0, 0, other)),
126
+    home = sum(ifelse(home < 0, 0, home)),
127 127
     total = sum(ifelse(total < 0, 0, total)), .groups="drop"
128 128
   ) -> edu_from
129 129
 
@@ -137,38 +137,38 @@ edu_simp %>% group_by(edu_code, edu_name, edu_east, edu_north) %>%
137 137
     pubbus = sum(ifelse(pubbus < 0, 0, pubbus)),
138 138
     train = sum(ifelse(train < 0, 0, train)),
139 139
     ferry = sum(ifelse(ferry < 0, 0, ferry)),
140
-    home = sum(ifelse(home < 0, 0, home)),
141 140
     other = sum(ifelse(other < 0, 0, other)),
141
+    home = sum(ifelse(home < 0, 0, home)),
142 142
     total = sum(ifelse(total < 0, 0, total)), .groups="drop"
143 143
   ) -> edu_to
144 144
 
145 145
 tencols <-  c("#f85654", "#e31a1c", "#1f78b4", "#6a3d9a", "#b2df8a", 
146
-              "#33a02c", "#fdbf6f", "#ff7f00", "#af8ac1", "#cab2d6")
146
+              "#33a02c", "#fdbf6f", "#ff7f00", "#cab2d6", "#af8ac1")
147 147
 tencols[which.max(work_from[1, 5:14])]
148 148
 
149 149
 
150
-work_from$MAX <- work_from %>% select(private:other) %>% as.matrix() %>% 
150
+work_from$MAX <- work_from %>% select(private:home) %>% as.matrix() %>% 
151 151
   apply(1, function(x) {
152 152
     ifelse(max(x) <= 0, NA, which.max(x))
153 153
     })
154
-work_to$MAX <- work_to %>% select(private:other) %>% as.matrix() %>% 
154
+work_to$MAX <- work_to %>% select(private:home) %>% as.matrix() %>% 
155 155
   apply(1, function(x) {
156 156
     ifelse(max(x) <= 0, NA, which.max(x))
157 157
     })
158
-work_simp$MAX <- work_simp %>% select(private:other) %>% as.matrix() %>% 
158
+work_simp$MAX <- work_simp %>% select(private:home) %>% as.matrix() %>% 
159 159
   apply(1, function(x) {
160 160
     ifelse(max(x) <= 0, NA, which.max(x))
161 161
     })
162 162
 
163
-edu_from$MAX <- edu_from %>% select(drive:other) %>% as.matrix() %>% 
163
+edu_from$MAX <- edu_from %>% select(drive:home) %>% as.matrix() %>% 
164 164
   apply(1, function(x) {
165 165
     ifelse(max(x) <= 0, NA, which.max(x))
166 166
     })
167
-edu_to$MAX <- edu_to %>% select(drive:other) %>% as.matrix() %>% 
167
+edu_to$MAX <- edu_to %>% select(drive:home) %>% as.matrix() %>% 
168 168
   apply(1, function(x) {
169 169
     ifelse(max(x) <= 0, NA, which.max(x))
170 170
     })
171
-edu_simp$MAX <- edu_simp %>% select(drive:other) %>% as.matrix() %>% 
171
+edu_simp$MAX <- edu_simp %>% select(drive:home) %>% as.matrix() %>% 
172 172
   apply(1, function(x) {
173 173
     ifelse(max(x) <= 0, NA, which.max(x))
174 174
     })

+ 3
- 3
viz/app.R View File

@@ -16,10 +16,10 @@ sa.in.dest <- shpf@data$SA22018_V1 %in% work_to$work_code
16 16
 sa.in.home <- shpf@data$SA22018_V1 %in% work_from$res_code
17 17
 transport.t <- c("Private car", "Passenger in car",
18 18
                  "Walk", "Bicycle", "Company car", "Bus", "Train",
19
-                 "Ferry", "Work at home", "Other", "None/Unknown")
19
+                 "Ferry", "Other", "(Work at home)", "None/Unknown")
20 20
 edu.t <- c("Drive self", "Passenger in car", "Walk", "Bicycle",
21
-           "School bus", "Public bus", "Train", "Ferry", "Study at home",
22
-           "Other", "None/Unknown")
21
+           "School bus", "Public bus", "Train", "Ferry",
22
+           "Other", "(Study at home)", "None/Unknown")
23 23
 cols.labs <- c(transport.t[1:10], "Total")
24 24
 cols.edu.labs <- c(edu.t[1:10], "Total")
25 25