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
   bus = Public_bus,
46
   bus = Public_bus,
47
   train = Train,
47
   train = Train,
48
   ferry = Ferry,
48
   ferry = Ferry,
49
-  home = Work_at_home,
50
   other = Other,
49
   other = Other,
50
+  home = Work_at_home,
51
   total = Total
51
   total = Total
52
 ) -> work_simp
52
 ) -> work_simp
53
 
53
 
65
     bus = sum(ifelse(bus < 0, 0, bus)),
65
     bus = sum(ifelse(bus < 0, 0, bus)),
66
     train = sum(ifelse(train < 0, 0, train)),
66
     train = sum(ifelse(train < 0, 0, train)),
67
     ferry = sum(ifelse(ferry < 0, 0, ferry)),
67
     ferry = sum(ifelse(ferry < 0, 0, ferry)),
68
-    home = sum(ifelse(home < 0, 0, home)),
69
     other = sum(ifelse(other < 0, 0, other)),
68
     other = sum(ifelse(other < 0, 0, other)),
69
+    home = sum(ifelse(home < 0, 0, home)),
70
     total = sum(ifelse(total < 0, 0, total)), .groups="drop"
70
     total = sum(ifelse(total < 0, 0, total)), .groups="drop"
71
   ) -> work_from
71
   ) -> work_from
72
     
72
     
85
     bus = sum(ifelse(bus < 0, 0, bus)),
85
     bus = sum(ifelse(bus < 0, 0, bus)),
86
     train = sum(ifelse(train < 0, 0, train)),
86
     train = sum(ifelse(train < 0, 0, train)),
87
     ferry = sum(ifelse(ferry < 0, 0, ferry)),
87
     ferry = sum(ifelse(ferry < 0, 0, ferry)),
88
-    home = sum(ifelse(home < 0, 0, home)),
89
     other = sum(ifelse(other < 0, 0, other)),
88
     other = sum(ifelse(other < 0, 0, other)),
89
+    home = sum(ifelse(home < 0, 0, home)),
90
     total = sum(ifelse(total < 0, 0, total)), .groups="drop"
90
     total = sum(ifelse(total < 0, 0, total)), .groups="drop"
91
   ) -> work_to
91
   ) -> work_to
92
 
92
 
107
   pubbus = Public_bus,
107
   pubbus = Public_bus,
108
   train = Train,
108
   train = Train,
109
   ferry = Ferry,
109
   ferry = Ferry,
110
-  home = Study_at_home,
111
   other = Other,
110
   other = Other,
111
+  home = Study_at_home,
112
   total = Total
112
   total = Total
113
 )
113
 )
114
 
114
 
122
     pubbus = sum(ifelse(pubbus < 0, 0, pubbus)),
122
     pubbus = sum(ifelse(pubbus < 0, 0, pubbus)),
123
     train = sum(ifelse(train < 0, 0, train)),
123
     train = sum(ifelse(train < 0, 0, train)),
124
     ferry = sum(ifelse(ferry < 0, 0, ferry)),
124
     ferry = sum(ifelse(ferry < 0, 0, ferry)),
125
-    home = sum(ifelse(home < 0, 0, home)),
126
     other = sum(ifelse(other < 0, 0, other)),
125
     other = sum(ifelse(other < 0, 0, other)),
126
+    home = sum(ifelse(home < 0, 0, home)),
127
     total = sum(ifelse(total < 0, 0, total)), .groups="drop"
127
     total = sum(ifelse(total < 0, 0, total)), .groups="drop"
128
   ) -> edu_from
128
   ) -> edu_from
129
 
129
 
137
     pubbus = sum(ifelse(pubbus < 0, 0, pubbus)),
137
     pubbus = sum(ifelse(pubbus < 0, 0, pubbus)),
138
     train = sum(ifelse(train < 0, 0, train)),
138
     train = sum(ifelse(train < 0, 0, train)),
139
     ferry = sum(ifelse(ferry < 0, 0, ferry)),
139
     ferry = sum(ifelse(ferry < 0, 0, ferry)),
140
-    home = sum(ifelse(home < 0, 0, home)),
141
     other = sum(ifelse(other < 0, 0, other)),
140
     other = sum(ifelse(other < 0, 0, other)),
141
+    home = sum(ifelse(home < 0, 0, home)),
142
     total = sum(ifelse(total < 0, 0, total)), .groups="drop"
142
     total = sum(ifelse(total < 0, 0, total)), .groups="drop"
143
   ) -> edu_to
143
   ) -> edu_to
144
 
144
 
145
 tencols <-  c("#f85654", "#e31a1c", "#1f78b4", "#6a3d9a", "#b2df8a", 
145
 tencols <-  c("#f85654", "#e31a1c", "#1f78b4", "#6a3d9a", "#b2df8a", 
146
-              "#33a02c", "#fdbf6f", "#ff7f00", "#af8ac1", "#cab2d6")
146
+              "#33a02c", "#fdbf6f", "#ff7f00", "#cab2d6", "#af8ac1")
147
 tencols[which.max(work_from[1, 5:14])]
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
   apply(1, function(x) {
151
   apply(1, function(x) {
152
     ifelse(max(x) <= 0, NA, which.max(x))
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
   apply(1, function(x) {
155
   apply(1, function(x) {
156
     ifelse(max(x) <= 0, NA, which.max(x))
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
   apply(1, function(x) {
159
   apply(1, function(x) {
160
     ifelse(max(x) <= 0, NA, which.max(x))
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
   apply(1, function(x) {
164
   apply(1, function(x) {
165
     ifelse(max(x) <= 0, NA, which.max(x))
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
   apply(1, function(x) {
168
   apply(1, function(x) {
169
     ifelse(max(x) <= 0, NA, which.max(x))
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
   apply(1, function(x) {
172
   apply(1, function(x) {
173
     ifelse(max(x) <= 0, NA, which.max(x))
173
     ifelse(max(x) <= 0, NA, which.max(x))
174
     })
174
     })

+ 3
- 3
viz/app.R View File

16
 sa.in.home <- shpf@data$SA22018_V1 %in% work_from$res_code
16
 sa.in.home <- shpf@data$SA22018_V1 %in% work_from$res_code
17
 transport.t <- c("Private car", "Passenger in car",
17
 transport.t <- c("Private car", "Passenger in car",
18
                  "Walk", "Bicycle", "Company car", "Bus", "Train",
18
                  "Walk", "Bicycle", "Company car", "Bus", "Train",
19
-                 "Ferry", "Work at home", "Other", "None/Unknown")
19
+                 "Ferry", "Other", "(Work at home)", "None/Unknown")
20
 edu.t <- c("Drive self", "Passenger in car", "Walk", "Bicycle",
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
 cols.labs <- c(transport.t[1:10], "Total")
23
 cols.labs <- c(transport.t[1:10], "Total")
24
 cols.edu.labs <- c(edu.t[1:10], "Total")
24
 cols.edu.labs <- c(edu.t[1:10], "Total")
25
 
25