Skip to content

Instantly share code, notes, and snippets.

@sckott
sckott / geo_json.R
Last active August 29, 2015 14:08 — forked from ateucher/geo_json.R
devtools::install_github("ropensci/togeojson@reworkapi")
library('togeojson')
library('maps')
data(us.cities)
to_geo_json(us.cities[1:2,], lat='lat', lon='long')
to_geojson(us.cities[1:2,], lat='lat', lon='long')
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Sinon.js fakeServer demo</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/sinon.js/1.7.3/sinon-min.js"></script>
<script src="sinon-fake-server.js"></script>
</head>
<body>
@sckott
sckott / server.r
Last active December 18, 2015 03:39 — forked from ramnathv/server.r
require(shiny)
require(rCharts)
shinyServer(function(input, output){
output$chart <- renderMap({
require(rCharts)
map3 <- Leaflet$new()
map3$setView(c(51.505, -0.09), zoom = 13)
map3$tileLayer(provider = input$provider, urlTemplate = NULL)
map3$marker(c(51.5, -0.09), bindPopup = "<p> Hi. I am a popup </p>")
@sckott
sckott / prepdata.R
Created December 10, 2012 22:58 — forked from emhart/server.R
rOpenSci rgbif shiny app test
splist <- c("Accipiter erythronemius", "Junco hyemalis", "Aix sponsa", "Haliaeetus leucocephalus",
"Corvus corone", "Threskiornis molucca", "Merops malimbicus")
out <- lapply(splist, function(x) occurrencelist(x, coordinatestatus=T, maxresults=500))
names(out) <- splist
setwd("~/ShinyApps/rgbif2")
save(out, file="speciesdata.rda")
@sckott
sckott / is.invasive.R
Created November 26, 2012 17:02 — forked from ibartomeus/is.invasive.R
This function check which species (both plants and animals) are considered "invaders" somewhere in the world.
is.invasive()
##Description##
#This function check which species (both plants and animals) are considered "invaders" somewhere in the
# world. For that end, it checks GISD (http://www.issg.org/database/welcome/) and returns a value, either
#"Not invasive" or the brief description presented in GISD. Note that the webpage contains more
#information. Also note that the function won't tell you if it's exotic in your area, a lot of exotic
#species are not considered invaders (yet). As expected, the function is as good as the database is, which
#I find quite reliable and well maintained. The database is also able to recognize a lot (but not all) of
@sckott
sckott / ggplot2SEM.R
Created May 1, 2012 05:23 — forked from emhart/ggplot2SEM.R
ggplot2 SEM model example
require(ggplot2); require(gridExtra)
###Generate box coords
###A function to generat a blank box for use with geom_path()
box_coords <- function(x,y,size){
b.x <- c(rep(x,2) - (size[1] / 2),rep(x,2) + (size[1] / 2))
b.x[5] <- b.x[1]
b.y <- c(y-(size[2] / 2),rep(y,2)+(size[2] / 2),y-(size[2] / 2))
b.y[5] <- b.y[1]
rmat <- data.frame(cbind(b.x,b.y))