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(shiny) | |
library(spdep) | |
library(leaflet) | |
library(RColorBrewer) | |
atx <- readRDS('travis.rds') | |
atx$id <- 1:nrow(atx) | |
atx2 <- atx[!is.na(atx$income), ] |
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(data.table) | |
alloc_opti_data.table=function(n=1000 | |
,dataset=ese_op2013_reste | |
,strate="strate2013" | |
,sd=ecart_type ) | |
{ | |
#count obs per strata to form Nh: | |
dataset=data.table(dataset) | |
output=dataset[,.N,by=strate] |
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
// assumes you add a timestamp field to each record (see Firebase.ServerValue.TIMESTAMP) | |
// pros: fast and done server-side (less bandwidth, faster response), simple | |
// cons: a few bytes on each record for the timestamp | |
var ref = new Firebase(...); | |
ref.orderByChild('timestamp').startAt(Date.now()).on('child_added', function(snapshot) { | |
console.log('new record', snap.key()); | |
}); |
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
function go() { | |
var userId = prompt('Username?', 'Guest'); | |
checkIfUserExists(userId); | |
} | |
var USERS_LOCATION = 'https://SampleChat.firebaseIO-demo.com/users'; | |
function userExistsCallback(userId, exists) { | |
if (exists) { | |
alert('user ' + userId + ' exists!'); |
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
import pandas | |
import rpy2.robjects as robjects | |
from rpy2.robjects.packages import importr | |
from rpy2.robjects.lib import grid | |
from rpy2.robjects.lib import ggplot2 | |
## read in the distances to railroad (we calculated) | |
neardist = pandas.read_csv('data/NearDistance.csv') | |
## convert to R dataframe, via Python Dictionary data type |