Skip to content

Commit

Permalink
Clustering files
Browse files Browse the repository at this point in the history
  • Loading branch information
julianflowers committed Feb 13, 2017
1 parent 48daa3a commit 8e67073
Show file tree
Hide file tree
Showing 23 changed files with 4,543 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
1 change: 1 addition & 0 deletions cluster.csv

Large diffs are not rendered by default.

278 changes: 278 additions & 0 deletions cluster1.html

Large diffs are not rendered by default.

278 changes: 278 additions & 0 deletions cluster10.html

Large diffs are not rendered by default.

278 changes: 278 additions & 0 deletions cluster11.html

Large diffs are not rendered by default.

278 changes: 278 additions & 0 deletions cluster12.html

Large diffs are not rendered by default.

278 changes: 278 additions & 0 deletions cluster13.html

Large diffs are not rendered by default.

278 changes: 278 additions & 0 deletions cluster14.html

Large diffs are not rendered by default.

278 changes: 278 additions & 0 deletions cluster15.html

Large diffs are not rendered by default.

278 changes: 278 additions & 0 deletions cluster2.html

Large diffs are not rendered by default.

278 changes: 278 additions & 0 deletions cluster3.html

Large diffs are not rendered by default.

278 changes: 278 additions & 0 deletions cluster4.html

Large diffs are not rendered by default.

278 changes: 278 additions & 0 deletions cluster5.html

Large diffs are not rendered by default.

278 changes: 278 additions & 0 deletions cluster6.html

Large diffs are not rendered by default.

278 changes: 278 additions & 0 deletions cluster7.html

Large diffs are not rendered by default.

278 changes: 278 additions & 0 deletions cluster8.html

Large diffs are not rendered by default.

278 changes: 278 additions & 0 deletions cluster9.html

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions geopractice.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX
1 change: 1 addition & 0 deletions hp.csv

Large diffs are not rendered by default.

278 changes: 278 additions & 0 deletions interactive_report.html

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions loop.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
library(rmarkdown)

for(cluster in 1:15) {

render("interactive_report.Rmd",
output_file = paste0("cluster", cluster, ".html"),
params = list(cluster = cluster))



}
55 changes: 55 additions & 0 deletions point_map.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
library(readr)
library(ggmap)
library(janitor)
library(leaflet)

## Download GP data from data.gov.uk
gpdata <- read_tsv("http://data.gov.uk/data/resource/nhschoices/GP.csv")

gpdata <- gpdata %>% clean_names()

loc <- gpdata %>% select(latitude, longitude)
loc <- slice(loc, 5:30)
mymap <- get_map("England", source = "google", maptype = "roadmap", zoom = 6)
ggmap(mymap) + geom_jitter(aes( y = latitude, x= longitude), colour = organisationtype,
data = gpdata, size = 1, alpha = 0.5
) + coord


### Leaflet

gpdata %>%
leaflet() %>%
addTiles() %>%
addMarkers(~longitude, ~latitude, popup = ~organisationcode )
###

library(viridis)
gpclus <- read_csv("cluster.csv") %>% clean_names() %>% rename(organisationcode = x_area)

gpdata1 <- gpdata %>% left_join(gpclus)

mymap1 <- get_map("London", source = "google", maptype = "roadmap", zoom = 10)
map1 <- ggmap(mymap1) + geom_jitter(aes( y = latitude, x= longitude, colour = `_cluster`),
data = gpdata1, size = 1.5, alpha = 0.9) +
scale_color_viridis(option = "D") + coord_map()

mymap2 <- get_map("Newcastle", source = "google", maptype = "roadmap", zoom = 9)

map2 <- ggmap(mymap2) + geom_jitter(aes( y = latitude, x= longitude, colour = as.character(`_cluster`)),
data = gpdata1, size = 1.5, alpha = 0.9) +
scale_color_viridis(option = "D", discrete = TRUE) + coord_map()
map2


gpclus1 <- gpdata1 %>%
filter(`_cluster` == 15)

clusmap <- get_map("England", source = "google", maptype = "roadmap", zoom = 6)
ggmap(clusmap) + geom_jitter(aes( y = latitude, x= longitude, colour = as.character(`_cluster`)),
data = gpclus1, size = 1.5, alpha = 0.9) +
scale_color_viridis(option = "D", discrete = TRUE) + coord_map()

gpdata1 %>%
group_by(`_cluster`) %>%
count()
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: clustering
title: Clustering
account: julian_flowers
server: beta.rstudioconnect.com
appId: 2511
bundleId: 5271
url: https://beta.rstudioconnect.com/content/2511/
when: 1486977128.72954
asMultiple: FALSE
asStatic: FALSE

0 comments on commit 8e67073

Please sign in to comment.