There and Back Again competition entry https://shiny.petras.space/commute/
rstats
rshiny
census
competition
leaflet
javascript
stats-nz

scratch.R 959B

1234567891011121314151617181920212223242526272829
  1. library(readr)
  2. library(ggplot2)
  3. library(dplyr)
  4. library(igraph)
  5. education_travel <- read_csv("travel-education.csv")
  6. 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. ggplot(work_travel, aes(x = SA2_code_usual_residence_address,
  12. y = SA2_code_workplace_address,
  13. fill = Total)) +
  14. geom_tile()
  15. 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 )
  16. plot(g2)
  17. tg <- make_empty_graph()
  18. work_travel %>% filter(Total > 100) %>% select(SA2_name_usual_residence_address, SA2_name_workplace_address) %>%
  19. as.matrix %>% t %>% as.vector -> elist
  20. locgraph <- graph(edges = elist)
  21. # plot(locgraph, label = NA)
  22. sg <- decompose(locgraph, mode="weak")