This is a proof-of-concept on how one can use RStudio to livecode D3 visualizations.
You will need to install a couple of packages before getting started
devtools::install_github("yihui/servr")
--- | |
title: "twee demo" | |
author: "Jenny Bryan" | |
date: "17 August, 2014" | |
output: | |
html_document: | |
toc: TRUE | |
keep_md: TRUE | |
--- |
doInstall <- TRUE | |
toInstall <- c("XML", "maps", "ggplot2", "sp") | |
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")} | |
lapply(toInstall, library, character.only = TRUE) | |
myURL <- "http://en.wikipedia.org/wiki/United_States_presidential_election,_2012" | |
allTables <- readHTMLTable(myURL) | |
str(allTables) # Look at the allTables object to find the specific table we want | |
stateTable <- allTables[[14]] # We want the 14th table in the list (maybe 13th?) |
Data sources: | |
CDC data on vaccine coverage: http://www.cdc.gov/flu/professionals/vaccination/reporti1112/reporti/index.htm | |
CDC data on current influenza situation: http://gis.cdc.gov/grasp/fluview/fluportaldashboard.html | |
Historical flu data: http://www.cdc.gov/flu/weekly/pastreports.htm | |
Locations of hospitals in Boston: https://data.cityofboston.gov/Public-Health/Hospital-Locations/46f7-2snz | |
NetLogo, a simple agent based model: http://ccl.northwestern.edu/netlogo/ | |
Nemsis, emergency medical services API (haven't used this one myself): http://www.nemsis.org/v3/downloads/v3Archive.html | |
Written for R, but useful for epi basics in any language: cran.r-project.org/doc/contrib/Epicalc_Book.pdf | |
"Provides access to health statistics and information on hospital inpatient and emergency department utilization": http://hcupnet.ahrq.gov/ | |
Healthcare Research and Quality data directory: http://www.ahrq.gov/data/dataresources.htm |
# see github repos & package documentation | |
# - http://github.com/apache/spark/tree/master/R | |
# - http://spark.apache.org/docs/latest/api/R/ | |
# install the SparkR package | |
devtools::install_github("apache/spark", ref="master", subdir="R/pkg") | |
# load the SparkR & ggplot2 packages | |
library('SparkR') | |
library('ggplot2') |
library(SmarterPoland) | |
library(riverplot) | |
library(RColorBrewer) | |
library(graphics) | |
library(reshape2) | |
library(plyr) | |
library(stringr) | |
library(countrycode) | |
# DOWNLOAD THE DATA |
library('httr') | |
library('jsonlite') | |
get_measures <- function(deviceid) { | |
.h <- list( | |
"Origin" = "http://anasim.iet.unipi.it", | |
"Accept-Encoding" = "gzip, deflate", | |
"Accept-Language" = "it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4", | |
"User-Agent" = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36", |
library(stringi) | |
library(microbenchmark) | |
library(ggplot2) | |
library(readr) | |
ex <- "example.txt" | |
mb <- microbenchmark(readLines=readLines(ex), | |
read_lines=read_lines(ex), | |
stri_read_lines=stri_read_lines(ex)) |