This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"))) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ls_files=Sys.glob("*.json") | |
| tweetdf(jsonfile) | |
| tweetdf=function(jsonfile) { | |
| require(jsonlite) | |
| ex=jsonlite::fromJSON(jsonfile) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(rvest) | |
| meteo_site <- html("http://www.altostratus.it/Meteo_Site_Italy.htm") | |
| html_nodes(meteo_site, xpath = "//li//a") %>% html_text() | |
| html_nodes(meteo_site, xpath = "//li//a") %>% html_attr("href") | |
| saveRDS(meteo_site,"meteo_sites_italy.rds") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tm) | |
| library(tm.plugin.mail) | |
| read_file_string=function(filer) { | |
| con <- file(filer, "r", blocking = FALSE) | |
| singleString <- readLines(con) | |
| singleString <-paste(singleString, sep = " ", collapse = " ") | |
| close(con) | |
| return(singleString) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| outersect <- function(x, y) { | |
| sort(c(x[!x%in%y], | |
| y[!y%in%x])) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| outersect <- function(x, y, ...) { | |
| big.vec <- c(x, y, ...) | |
| duplicates <- big.vec[duplicated(big.vec)] | |
| setdiff(big.vec, unique(duplicates)) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # from a char vector | |
| extracts_tweet=function(text) { | |
| require(stringr) | |
| res=list() | |
| res$hashtags_text=unique(unlist(str_extract_all(text,'(#[[:alnum:]_]*)'))) | |
| res$links_text=unique(unlist(str_extract_all(text,'http[^[:blank:]]+'))) | |
| res$mentions_text=unique(unlist(str_extract_all(text,'(@[[:alnum:]_]*)'))) | |
| return(res) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import io, json,csv,sys,os | |
| from TwitterAPI import TwitterAPI | |
| if len(sys.argv) < 2: | |
| sys.exit('Usage: %s IDcsvfile' % sys.argv[0]) | |
| if not os.path.exists(sys.argv[1]): | |
| sys.exit('ERROR: filenot %s was not found!' % sys.argv[1]) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| import io, json | |
| from TwitterAPI import TwitterAPI | |
| CONSUMER_KEY = '' | |
| CONSUMER_SECRET = '' | |
| ACCESS_TOKEN_KEY = '' | |
| ACCESS_TOKEN_SECRET = '' |