Skip to content

Instantly share code, notes, and snippets.

@Isaquedanielre
Isaquedanielre / CreateRoutes.R
Created January 8, 2016 02:54 — forked from diegovalle/CreateRoutes.R
Decode polylines obtained from Google Maps
library(maptools)
library(maps)
library(mapdata)
library(rjson)
library(stringr)
library(RCurl)
library(ggplot2)
GetDirections <- function(from, to) {
@Isaquedanielre
Isaquedanielre / Google Directions API
Created December 17, 2015 02:10 — forked from sh4n3d4v15/Google Directions API
R functions to lookup distance and duration from two given points
library(RCurl)
library(RJSONIO)
library(plyr)
url <- function(origin, destination) {
root <- "https://maps.googleapis.com/maps/api/directions/json"
u <- paste(root, "?origin=", origin, "&destination=", destination, "&key=AIzaSyAuj0ix2b8t54hrhIEHRsQNk0r6y9eBK2U", sep = "")
return (URLencode(u))
}
@Isaquedanielre
Isaquedanielre / mode.R
Created December 2, 2015 00:13
R function to calculate the mode of a dataset.
Mode <- function(x) {
ux <- unique(x)
ux[which.max(tabulate(match(x, ux)))]
}