Project

library(rgdal)
## Loading required package: sp
## Warning: package 'sp' was built under R version 4.0.3
## rgdal: version: 1.5-16, (SVN revision 1050)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 3.0.4, released 2020/01/28
## Path to GDAL shared files: C:/Users/FiercePC/Documents/R/win-library/4.0/rgdal/gdal
## GDAL binary built with GEOS: TRUE 
## Loaded PROJ runtime: Rel. 6.3.1, February 10th, 2020, [PJ_VERSION: 631]
## Path to PROJ shared files: C:/Users/FiercePC/Documents/R/win-library/4.0/rgdal/proj
## Linking to sp version:1.4-2
## To mute warnings of possible GDAL/OSR exportToProj4() degradation,
## use options("rgdal_show_exportToProj4_warnings"="none") before loading rgdal.
library(sp)
library(maps)
## Warning: package 'maps' was built under R version 4.0.5
library(ggmap)
## Warning: package 'ggmap' was built under R version 4.0.3
## Loading required package: ggplot2
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
library(ggplot2)
library(maptools)
## Warning: package 'maptools' was built under R version 4.0.5
## Checking rgeos availability: TRUE

First Look

Reading Data

#london <- readOGR('houses_lr.geojson')

profiles <- read.csv('lb_profiles.csv')

crime <- read.csv('boroughCrime.csv')
  
#london_df <- as.data.frame(london)#dataframes are cooler than geojson

Boxplots

#boxplot(price ~ propertytype, data = london_df)

#boxplot(price ~ oldnew, data = london_df)

#boxplot(price ~ duration, data = london_df)

#boxplot(price ~ categorytype, data = london_df)

#boxplot(price ~ recordstatus, data = london_df)

#boxplot(price ~ year, data = london_df)

Profile Plots

# 1 denotes greater than average, 0 less than avg age
plotAvg <- function(col,title){
  col[is.na(col)] <- 0
  profiles$avgValue <- ifelse(col > mean(col),1,0)

ggplot(profiles, aes(x = reorder(NAME, -HousePrice), y = HousePrice, fill = as.factor(avgValue))) + 
  geom_bar(stat = 'identity' , position=position_dodge()) +
  coord_flip() +
  ggtitle(title)
}

plotAvg(profiles$PopDens, 'Population Density')

plotAvg(profiles$AveAge, 'Avg Age')

plotAvg(profiles$BornAbroad, 'Born Abroad')

plotAvg(profiles$Disabled, 'Disabled')

plotAvg(profiles$Degrees, 'Degrees')

plotAvg(profiles$CrimeRate, 'Crime Rate')

plotAvg(profiles$GreenSpace, 'Greenspace')

plotAvg(profiles$CarsHH, 'Cars Per Household')

plotAvg(profiles$NonEng, 'Non English Speaking') 

Crime Data Manipulation

crime$totCrime <- rowSums(crime[,4:27])

aggCrime <- data.frame(
  borough = unique(profiles$NAME),
  totalCrimes = 0
)

crimePlace <- data.frame(
  borough = unique(profiles$NAME),
  majorCategory = '',
  totalCrimes = 0
)