This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# packages | |
require(data.table) | |
require(leaflet) | |
require(readxl) | |
twoppReps <- as.data.table(read.csv("https://tallyroom.aec.gov.au/Downloads/HouseTppByPollingPlaceDownload-24310.csv", skip = 1L)) | |
pollingPlaces <- as.data.table(read.csv("https://tallyroom.aec.gov.au/Downloads/GeneralPollingPlacesDownload-24310.csv", skip = 1)) | |
operatingMines <- as.data.table(read_excel("C:/Users/mcoog/Dropbox/blogs/operating_mines.xls")) | |
# inner join to add lat and longtitude data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# how to draw a map -- and some geospatial points -- using R | |
require(data.table) | |
require(leaflet) | |
# get the data | |
pollingPlaces <- as.data.table(read.csv("https://tallyroom.aec.gov.au/Downloads/GeneralPollingPlacesDownload-24310.csv", skip = 1)) | |
nswReps <- as.data.table(read.csv("https://tallyroom.aec.gov.au/Downloads/HouseStateFirstPrefsByPollingPlaceDownload-24310-NSW.csv", skip = 1)) | |
# inner join to add lat and longtitude data | |
nswReps[pollingPlaces[, list(PollingPlaceID, Latitude, Longitude)], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(fredr) | |
require(xts) | |
# note you'll need an API key | |
fredr_set_key("123YourFREDAPIKey321") | |
# helper function to convert tib to xts | |
xtsT <- function(TIB) xts(TIB$value, TIB$date) | |
# helper function to remove rows that have NA values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<RcppArmadillo.h> | |
// [[Rcpp::depends(RcppArmadillo)]] | |
//[[Rcpp::export]] | |
arma::colvec getCoef(const arma::vec & X, const arma::vec & Y) { | |
// this function takes two numeric vectors | |
// checks to make sure the dimensions match | |
// returns the coefficients from a bivariate regression | |
// TODO: add an intercept switch ... noInt |