Skip to content

Instantly share code, notes, and snippets.

View alfcrisci's full-sized avatar

Alfonso alfcrisci

View GitHub Profile
#Load the packages
library(ggplot2)
library(maptools)
library(OpenStreetMap)
gpclibPermit()
#Import the data
text <- download.file("https://raw.github.com/alstat/Analysis-with-Programming/master/2013/R/R-Mapping-Super-Typhoon-Yolanda-Haiyan-Track/TyDatYolanda2013.csv",
destfile = "/tmp/test.csv", method = "curl")
tydat <- read.csv("/tmp/test.csv", header = TRUE)
###################################
## CartoDB 2.0 Install [Working] ##
## Tested on Ubuntu 12.04 ##
###################################
# Change password
passwd
adduser [username]
adduser [username] sudo
@alfcrisci
alfcrisci / pane_a_matera.geojson
Created May 17, 2014 14:42
Panifici a Matera con OpenStreetMap
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
curl -s "http://talos.irpi.cnr.it/zareport/za.php?action=get_full_report_data&cod=Tosc-A2"
@alfcrisci
alfcrisci / corstar.R
Last active August 29, 2015 14:13 — forked from aL3xa/corstar.R
corstar <- function(x, y = NULL, use = "pairwise", method = "pearson", round = 3, row.labels, col.labels, ...) {
require(psych)
ct <- corr.test(x, y, use, method) # calculate correlation
r <- ct$r # get correlation coefs
p <- ct$p # get p-values
stars <- ifelse(p < .001, "***", ifelse(p < .01, "** ", ifelse(p < .05, "* ", " "))) # generate significance stars
import io, json
from TwitterAPI import TwitterAPI
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
ACCESS_TOKEN_KEY = ''
ACCESS_TOKEN_SECRET = ''
api = TwitterAPI(CONSUMER_KEY,
CONSUMER_SECRET,
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
viewwhere<-function(object,zoom = 17){
require(leaflet)
if (is.null(object$lon) && is.null(object$lat))
{ stop("Object must be have coordinates lat and lon slot." )};
m = leaflet() %>% addTiles()
m = m %>% setView(object$lon, object$lat, zoom = zoom)
m %>% addPopups(object$lon,object$lat, paste0('The location of the object is here!'))
return(m)
listfiles=gsub(".shp","",Sys.glob("*.shp"))
read_project=function(x)
{
require(maptools)
require(rgdal)
temp=readShapePoly(x)
proj4string(temp)=CRS("+init=epsg:32632")
return(spTransform(temp, CRS("+init=epsg:4326")))
}
@alfcrisci
alfcrisci / read_tweet_json.r
Last active August 29, 2015 14:17
to read in Mearelli style json tweet object
ls_files=Sys.glob("*.json")
tweetdf(jsonfile)
tweetdf=function(jsonfile) {
require(jsonlite)
ex=jsonlite::fromJSON(jsonfile)