knitr::opts_chunk$set(echo = TRUE)
# crayon needs to be explicitly activated in Rmd options(crayon.enabled = TRUE) # Hooks needs to be set to deal with outputs # thanks to fansi logic old_hooks <- fansi::set_knit_hooks(knitr::knit_hooks, which = c("output", "message", "error"))
BOM maintains a shapefile of radar site names and their geographic locations. For ease, we'll just use the .dbf file part of the shapefile to extract the product codes and radar locations. The file is available from BOM's anonymous FTP server with spatial data ftp://ftp.bom.gov.au/anon/home/adfd/spatial/, specifically the DBF file portion of a shapefile, ftp://ftp.bom.gov.au/anon/home/adfd/spatial/IDR00007.dbf.
curl::curl_download( "ftp://ftp.bom.gov.au/anon/home/adfd/spatial/IDR00007.dbf", destfile = paste0(tempdir(), "radar_locations.dbf"), mode = "wb", quiet = TRUE ) new_radar_locations <- foreign::read.dbf(paste0(tempdir(), "radar_locations.dbf"), as.is = TRUE) new_radar_locations$LocationID <- ifelse( test = nchar(new_radar_locations$LocationID) == 1, yes = paste0("0", new_radar_locations$LocationID), no = new_radar_locations$LocationID ) data.table::setDT(new_radar_locations) data.table::setkey(new_radar_locations, "Name") str(new_radar_locations)
To ensure that the data being compared is from the most recent release, reinstall bomrang from CRAN.
install.packages("bomrang", repos = "http://cran.us.r-project.org") load(system.file("extdata", "radar_locations.rda", package = "bomrang")) ( radar_location_changes <- diffobj::diffPrint(new_radar_locations, radar_locations) )
Save the radar stations' metadata and changes to disk for use in bomrang.
if (!dir.exists("../inst/extdata")) { dir.create("../inst/extdata", recursive = TRUE) } radar_locations <- new_radar_locations save(radar_locations, file = "../inst/extdata/radar_locations.rda", compress = "bzip2") save(radar_location_changes, file = "../inst/extdata/radar_location_changes.rda", compress = "bzip2")
sessioninfo::session_info()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.