⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
This file contains 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("foreign") | |
library("rgdal") | |
library("sp") | |
library("spdep") | |
library("maptools") | |
library("SpatialEpi") | |
library("plyr") | |
data <- read.dbf("counts.dbf") | |
shapes <- readShapePoly("counts.shp") |
This file contains 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
require("lattice") | |
require("makeR") | |
#################################################################### | |
#################################################################### | |
#################################################################### | |
#################################################################### | |
levelplot.forumula <- function (x, data = NULL, allow.multiple = is.null(groups) || | |
outer, outer = TRUE, aspect = "fill", panel = if (useRaster) lattice.getOption("panel.levelplot.raster") else lattice.getOption("panel.levelplot"), |
This file contains 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
data$date <- as.POSIXlt(data$unix_time, origin="1970-01-01", tz="America/New_York") | |
data$date <- as.Date(data$date, format="%Y-%m-%d") |
This file contains 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
#_______________________________________________________________________________# | |
#| |# | |
#| !! keep in mind that each data frame must have only one common field name!! |# | |
#|_____________________________________________________________________________|# | |
#create the function for csvs | |
merge.csv = function(mypath){ | |
filenames=list.files(path=mypath, full.names=TRUE) | |
datalist = lapply(filenames, function(x){read.csv(file=x,header=T, stringsAsFactors=F)}) |
This file contains 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
#// Say you were building a dataset and wanted to automatically | |
#// generate variable names by some pattern. | |
#// For instance, you might want to do this with population counts | |
#// within 100 census tracts by race | |
#// IE: | |
# | |
# tracts <- paste("c", rep(1:100), sep="") | |
# race - c("black", "white", "hispanic") | |
# | |
#// In this case you would want to generate 300 unique variable names |
This file contains 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
#see below for query specifications | |
getInsights <- function( | |
username = "Insights4R@gmail.com", | |
password = "googleinsights4r", | |
text_query = "'hello world'", | |
date_query = "1/2004 108m", | |
geo_query = "US", | |
search_type= "all", | |
filter_category="none"){ |
This file contains 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
path_to_file = "~/Desktop/Vizzuality-cartodb-r-05eb537/CartoDB_1.4.tar.gz" | |
install.packages(path_to_file, repos=NULL, type="source") | |
require("CartoDB") | |
account_name = "parks-datadive" | |
api_key = "[ON THE BOARD IN 517-F]" | |
cartodb(account_name, api_key) | |
cartodb.test() |
This file contains 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
# Get a lat/lon value for each address | |
geocode.addr <- function(city, country) { | |
geo.url <- "http://maps.googleapis.com/maps/api/geocode/json?address=" | |
geo.text <- getURL(paste(geo.url, URLencode(paste(city, country, collapse="+")), "&sensor=false", sep="")) | |
geo.json <- fromJSON(geo.text) | |
if(geo.json$status == "OK"){ | |
return(geo.json$results[[1]]$geometry$location) | |
} | |
else{ |
OlderNewer