From d716d4c0cfd41403bd206a735e250e09cdfc3644 Mon Sep 17 00:00:00 2001 From: Daniel Berry Date: Sun, 13 Nov 2016 16:41:52 -0500 Subject: [PATCH] Whoops --- ETL.r | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ETL.r b/ETL.r index d66d298..4bbdc70 100644 --- a/ETL.r +++ b/ETL.r @@ -20,19 +20,19 @@ compute.center <- function(coords) {c(mean(coords[,1]), mean(coords[,2]))} blocks_raw <- read.csv('CensusBlockTIGER2010.csv', stringsAsFactors = FALSE) -blocks_raw <- blocks_raw[apply(!is.na(blocks_raw[,c('Longitude', 'Latitude')]), 1, any),] + centers <- do.call('rbind', lapply(blocks_raw$the_geom, function(s) compute.center(mp.to.matrix(s)))) blocks_raw$Longitude <- centers[,1] blocks_raw$Latitude <- centers[,2] +blocks_raw <- blocks_raw[apply(!is.na(blocks_raw[,c('Longitude', 'Latitude')]), 1, any),] + vacant_raw <- read.csv('311_Service_Requests_-_Vacant_and_Abandoned_Buildings_Reported_-_Map.csv', stringsAsFactors = FALSE, skip = 1) -vacant_raw <- vacant_raw[apply(!is.na(vacant_raw[,c('Longitude', 'Latitude')]), 1, any),] - names(vacant_raw) <- c('Type', 'ID', 'Date_Recieved', @@ -54,6 +54,8 @@ names(vacant_raw) <- c('Type', 'Longitude', 'Location_string') +vacant_raw <- vacant_raw[apply(!is.na(vacant_raw[,c('Longitude', 'Latitude')]), 1, any),] + ## tmp <- geo_full_join(blocks_raw[1:1,], vacant_raw[1:1,], by = c('Longitude', 'Latitude'), distance_col = 'dist') ## system.time(dist_mat <- distm(blocks_raw[1:1000,c('Longitude','Latitude')], vacant_raw[1:1000,c('Longitude','Latitude')]))