Skip to content

Instantly share code, notes, and snippets.

@Tadge-Analytics
Created October 20, 2019 02:53
Show Gist options
  • Save Tadge-Analytics/63f75895f0b2e76dae60c1bd5ce8fec7 to your computer and use it in GitHub Desktop.
Save Tadge-Analytics/63f75895f0b2e76dae60c1bd5ce8fec7 to your computer and use it in GitHub Desktop.
library(tidyverse)
library(httr)
# retrieve the data from the web
url <- "https://www.vcglr.vic.gov.au/sites/default/files/current_victorian_licences_by_location_august_2019.xlsx"
GET(url, write_disk(tf <- tempfile(fileext = ".xlsx")))
downloaded_data <- readxl::read_excel(tf, col_names = F, col_types = "text")
# process the download
vcglr_data <- downloaded_data %>%
slice(-c(1:2)) %>%
select(-`...7`, -`...13`, -`...14`) %>%
set_names(as.character(unlist(.[1,]))) %>%
slice(-1) %>%
filter(
!(
is.na(Latitude) |
is.na(Longitude) |
Latitude == "0.00000000" |
Longitude == "0.00000000" |
is.na(`Trading As`) |
`Trading As` == "." |
`Licence Num` %in% c("32350621", "32339162"))
) %>%
distinct(Latitude, Longitude, .keep_all = T) %>%
mutate(`Licence Num` = as.integer(`Licence Num`),
Latitude = as.numeric(Latitude),
Longitude = as.numeric(Longitude))
saveRDS(vcglr_data, "rds files/vcglr_data.rds")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment