The svgPanZoom
htmlwidget featured in WEEK 02 | PAN & ZOOM R PLOTS claims that it easily adds pan and zoom interactivity to nearly all R graphs. Here we try out svgPanZoom
on a couple of finance charts.
Live Examples
Code to reproduce code.r
## Determine CRAN package clusters (communities) | |
library(miniCRAN) | |
library(igraph) | |
library(magrittr) | |
# Download matrix of available packages at specific date ------------------ |
# devtools::install_github("jeroenooms/curl") | |
# devtools::install_github("jeroenooms/V8") | |
library(V8) | |
ct = new_context() | |
# get source and remove anonymous function wrapper | |
t = readLines( | |
"https://raw.githubusercontent.com/twitter/twitter-text/master/js/twitter-text.js" |
library(httr) | |
library(magrittr) | |
library(dplyr) | |
library(ggplot2) | |
# data retrieval ---------------------------------------------------------- | |
pg <- GET("http://data.giss.nasa.gov/gistemp/tabledata_v3/GLB.Ts+dSST.txt", | |
user_agent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A")) |
library(DiagrammeR) | |
mat <- structure( | |
c(0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, | |
0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, | |
0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, | |
0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, | |
1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, | |
0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, |
The svgPanZoom
htmlwidget featured in WEEK 02 | PAN & ZOOM R PLOTS claims that it easily adds pan and zoom interactivity to nearly all R graphs. Here we try out svgPanZoom
on a couple of finance charts.
Live Examples
Code to reproduce code.r
library(V8) | |
stopifnot(packageVersion("V8") >= "0.5") | |
# Create V8 context and load viz.js | |
ct <- new_context("window") | |
invisible(ct$source('http://mdaines.github.io/viz.js/viz.js')) | |
# This runs: Viz("digraph { a -> b; }", "svg") | |
svg <- ct$call("Viz", "digraph { a -> b; }", "svg") | |
cat(svg) |
library(V8) | |
# Create function to generate palette of visually different colors | |
hex_palette <- function(no_colors, | |
hue_range = NULL, | |
chroma_range = NULL, | |
lightness_range = NULL){ | |
pal <- function(col, border = "light gray", ...){ | |
n <- length(col) |
geojsonio has two ways to validate geojson (specifically geojson, not json structure itself). Via a web API from geojsonlint, or locally using the Mapbox's javascript geojsonhint library (included in the package).
Both can act directly on many different inputs, including character strings, lists, data.frame's, all the sp
class spatial objects.
library(dplyr) | |
library(streamgraph) | |
library(pbapply) | |
# Grab some employment data from BLS -------------------------------------- | |
url <- "http://www.bls.gov/lau/ststdsadata.txt" | |
dat <- readLines(url) | |
# Small function to grab data for a particular state ---------------------- |
# Obtain 'dogs.csv' | |
# Created by Alex Bresler, available at: | |
# https://github.com/abresler/abresler.github.io/blob/master/blog/2015/february/exploring_agility_show/data/dogs.csv | |
dat_url <- "http://asbcllc.com/blog/2015/february/exploring_agility_show/data/dogs.csv" | |
dogs <- read.csv(dat_url, header = TRUE, stringsAsFactors = FALSE) | |
library(shiny) | |
# Install the latest DiagrammeR package from GitHub | |
# devtools::install_github("rich-iannone/DiagrammeR") |