Recently Published
Olive R
one=Environment
two=Experience
three=Food
four=Service
Env/exp
one=Environment
two=Experience
three=Food
four=Service
Streamgraph
library(dplyr)
library(babynames)
library(streamgraph)
babynames %>%
filter(grepl("^(Alex|Bob|Jay|David|Mike|Jason|Stephen|Kymberlee|Lane|Sophie|John|Andrew|Thibault|Russell)$", name)) %>%
group_by(year, name) %>%
tally(wt=n) %>%
streamgraph("name", "n", "year", offset="zero", interpolate="linear") %>%
sg_legend(show=TRUE, label="DDSec names: ")
density.pp
coordinates(tabs) = ~lng1+lat1
zn1 <- as(tabs["average"], "ppp")
zn1
plot(zn1)
house.kde<-density(zn1, sigma=bw.diggle(zn1),weights=weights)
plot(house.kde)
contour(house.kde)
co <- colourmap(rainbow(4), range=c(0,4))
contour(house.kde, col=co, nlevels=5000,axes=TRUE)
density.pp
data(tabs)
coordinates(tabs) = ~lng1+lat1
zn1 <- as(tabs["average"], "ppp")
zn1
plot(zn1)
house.kde<-density(zn1, sigma=bw.diggle(zn1))
plot(house.kde)
contour(house.de)
co <- colourmap(rainbow(100), range=c(0,20))
contour(house.kde, col=co, nlevels=500,axes=TRUE)
Dsg <- as(house.kde, "SpatialGridDataFrame") # convert to spatial grid class
Dim <- as.image.SpatialGridDataFrame(Dsg) # convert again to an image
Dcl <- contourLines(Dim, nlevels = 500) # create contour object - change 8 for more/fewer levels!!!!!!!!!!
SLDF <- ContourLines2SLDF(Dcl, CRS(proj4string(Dsg))) # convert to SpatialLinesDataFrame
plot(SLDF, col = terrain.colors(500))
Publish Plot
ggmap(jogeva_map_g_str_m, extent = "device") + geom_density2d(data = jg_housing_xy_wgs84,
aes(x = lon, y = lat), size = 0.3) + stat_density2d(data = jg_housing_xy_wgs84,
aes(x = lon, y = lat, fill = ..level.., alpha = ..level..), size = 0.01,
bins = 16, geom = "polygon") + scale_fill_gradient(low = "green", high = "red",
guide = FALSE) + scale_alpha(range = c(0, 0.3), guide = FALSE)
http://www.geo.ut.ee/aasa/LOOM02331/heatmap_in_R.html
Heat maps
http://www.geo.ut.ee/aasa/LOOM02331/heatmap_in_R.html
Krigging map
http://stackoverflow.com/questions/26143699/options-to-allow-heavily-weighted-points-on-a-map-to-overwhelm-other-points-with
Publish Plot
est <- ci2d(geyser$lng1, geyser$lat1, show="none",method="bkde2D",nbins=150,ci.levels=c(0.05,0.5,0.75,0.8,0.95))
names(est$contours) ## show available contours
ci.5 <- est$contours[names(est$contours)=="0.5"] # get region(s)
ci.5
http://artax.karlin.mff.cuni.cz/r-help/library/gplots/html/ci2d.html
ci2d
https://github.com/cran/gplots/blob/master/R/ci2d.R, http://www.inside-r.org/packages/cran/gplots/docs/ci2d
ci2d
https://github.com/cran/gplots/blob/master/R/ci2d.R, http://www.inside-r.org/packages/cran/gplots/docs/ci2d
confidence interval
http://www.inside-r.org/packages/cran/gplots/docs/ci2d
Publish Plot
bos_plot+
+ stat_density2d(data= drugs, aes(x = drugs$lng1, y = drugs$lat1, alpha=.01,fill=..level..),bins=500, geom = 'polygon')+
+ guides(fill = guide_colorbar(barwidth = 1, barheight = 12)) +
+ scale_alpha(guide = FALSE)+
+ xlab(' ')+ylab(' ')+
+ ggtitle('FDI - 1991-2014')
correct kernel density file: http://stackoverflow.com/questions/34410999/why-is-bins-parameter-unknown-for-the-stat-density2d-function-ggmap
1991-2014
boston=read.csv('http://abuchel.physics.uwo.ca/~obuchel/ivey_research/1991_2014_1.csv')
> ## subset to drug crimes
> drugs=boston
>
> ## plot drug and shooting crimes
> bos_plot=ggmap(get_map('Shnaghai,China',
+ zoom=5,
+ source='google',
+ maptype='terrain'))
> ## Density areas
> bos_plot +
+ # density areas
+ stat_density2d(data = drugs,
+ aes(x = drugs$lng1, y = drugs$lat1, alpha=.75,fill=..level..),
+ geom = 'polygon')+
+ #density legend
+ guides(fill = guide_colorbar(barwidth = 0.01, barheight = 10)) +
+ # crime data points
+ geom_point(data=drugs,aes(x=drugs$lng1,y=drugs$lat1),
+ col='red', alpha=.5,size=1)+
+ scale_alpha(guide = FALSE)+
+ # Labels/Title
+ xlab('')+ylab('')+
+ ggtitle('FDI - 1993-2014')
Kernel density
http://stackoverflow.com/questions/25847188/geographical-heat-map-of-a-custom-property-in-r-with-ggmap
Hotspot plot
http://www.jonzelner.net/mapping/r/2014/07/08/hotspotr/
Filled Contour
http://www2.warwick.ac.uk/fac/sci/moac/people/students/peter_cock/r/density/
Density plots
<a href="http://www2.warwick.ac.uk/fac/sci/moac/people/students/peter_cock/r/density/" target="_blank">Link></a>
VecStatGraphs2D package
http://finzi.psych.upenn.edu/library/VecStatGraphs2D/html/DrawDensityMap.html