library(readxl)
d <- read_excel("REACT1_r6_final.xlsx", 
    sheet = "ltla_prevalence")

dt(d)
hist(d$prevalence)

d2 <- read_excel("REACT1_r6_final.xlsx")
d2$date <-d2$`Last sample`
d2$prevalence <- d2$`Positive swabs`/d2$`Tested swabs`

ggplot(d2, aes(x=date,y=prevalence)) + geom_point()
## Warning: Removed 2 rows containing missing values (geom_point).

dir(path="Data/GB",pattern="shp")
##  [1] "county_electoral_division_region.shp"    
##  [2] "county_region.shp"                       
##  [3] "district_borough_unitary_region.shp"     
##  [4] "district_borough_unitary_ward_region.shp"
##  [5] "european_region_region.shp"              
##  [6] "greater_london_const_region.shp"         
##  [7] "high_water_polyline.shp"                 
##  [8] "parish_region.shp"                       
##  [9] "scotland_and_wales_const_region.shp"     
## [10] "scotland_and_wales_region.shp"           
## [11] "unitary_electoral_division_region.shp"   
## [12] "westminster_const_region.shp"
library(sf)
## Linking to GEOS 3.5.1, GDAL 2.1.2, PROJ 4.9.3
library(mapview)
library(RColorBrewer)
la<-st_read("Data/GB/district_borough_unitary_region.shp")
## Reading layer `district_borough_unitary_region' from data source `/home/rstudio/webpages/epidemiology/react1/Data/GB/district_borough_unitary_region.shp' using driver `ESRI Shapefile'
## Simple feature collection with 368 features and 15 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 5512.998 ymin: 5333.81 xmax: 655989 ymax: 1220302
## epsg (SRID):    NA
## proj4string:    +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +datum=OSGB36 +units=m +no_defs
la<-st_simplify(la,dTol=1000)
la$ltla_code<-as.character(la$CODE)

la<-merge(la,d)
la$prevalenceper<-la$prevalence*100
pal<-brewer.pal(7, "RdYlGn")[7:1]
mapview(la,zcol="prevalenceper", at = c(0,0.1,0.2,0.5,1,2,3,4), col.regions=pal)
dt(d2)