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(ggvis) | |
x <- seq(-4, 4, .1) | |
dat <- data.frame(x, y=dnorm(x)) | |
g1 <- ggvis(dat, props(x = ~x, y = ~y), mark_path()) | |
shinyServer(function(input, output, session) { | |
# A subset of mtcars | |
dat2 <- reactive({ dat[dat$x <= input$z,] }) |
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
#This example will require version 0.0.5 of XML2R | |
library(devtools) | |
install_github("XML2R", "cpsievert") | |
library(XML2R) | |
#you could use multiple files here if you wanted... | |
files <- "https://www.misoenergy.org/ria/Consolidated.aspx?format=xml" | |
obs <- XML2Obs(files) | |
names(obs)[grep("PricingNode", names(obs))] <- "PricingNode" | |
tables <- collapse_obs(obs) | |
head(tables[[5]]) |
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(XML2R) | |
file <- "http://stats.oecd.org/restsdmx/sdmx.ashx/GetData/UN_DEN/AUS+CAN+FRA+DEU+NZL+GBR+USA+OECD/OECD?startTime=1960&endTime=2012" | |
obs <- XML2Obs(file) | |
# Rename observations so we can 'recycle' country labels to time/value | |
nms <- names(obs) | |
nms[grepl("SeriesKey//Value$", nms)] <- "root" | |
nms[grepl("Obs//Time$", nms)] <- "root//time" | |
nms[grepl("Obs//ObsValue$", nms)] <- "root//value" |
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(pitchRx) | |
library(dplyr) | |
library(mgcv) | |
# Establish a SQLite database connection | |
my_db <- src_sqlite("pitchRx.sqlite3") | |
# DISLCAIMER: this 'pitchfx.sqlite3' database was obtained using pitchRx version 1.2 | |
# The code below probably won't work if you are using data collected from earlier versions or other methods | |
# Anyway, if you want to recreate this analysis, make sure you have pitchRx 1.2 or higher, then run: |
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
--- | |
output: | |
knitrBootstrap::bootstrap_document: | |
title: "Stat 226 Home Page" | |
theme: amelia | |
highlight: sunburst | |
theme.chooser: TRUE | |
highlight.chooser: TRUE | |
bootstrap.panel: FALSE | |
--- |
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(XML) | |
library(RCurl) | |
library(stringr) | |
library(elife) | |
# Obtain all the dois! Well, at least every one on GitHub. | |
# Should/could this be an option in searchelife? It doesn't take that long... | |
con <- getURL("https://github.com/elifesciences/elife-articles") | |
doc <- htmlParse(con, asText = TRUE) | |
nodes <- getNodeSet(doc, path="//a[@class='js-directory-link']") |
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(pitchRx) | |
library(colorspace) | |
vals <- rainbow_hcl(361) | |
data(pitches) | |
pitches$spin_dir <- with(pitches, factor(round(spin_dir), levels = seq(0, 360))) | |
p1 <- strikeFX(pitches, color = "spin_dir", point.alpha = 0.3, | |
adjust = TRUE, contour = TRUE) + facet_grid(pitch_type ~ stand) + | |
theme(legend.position = "none") + | |
scale_colour_manual(values = vals) + coord_equal() |
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
// Define functions to render linked interactive plots using d3. | |
// Another script should define e.g. | |
// <script> | |
// var plot = new animint("#plot","path/to/plot.json"); | |
// </script> | |
// Constructor for animint Object. | |
var animint = function (to_select, json_file) { | |
var dirs = json_file.split("/"); | |
dirs.pop(); //if a directory path exists, remove the JSON file from dirs | |
var element = d3.select(to_select); |
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(devtools) | |
install_github("ramnathv/rCharts") | |
# This will soon have to be install_github("rOpenSci/gistr"); see convo here https://twitter.com/ramnath_vaidya/status/469160178898989056 | |
library(rCharts) | |
# set your GitHub username and password | |
options(github.username = "foo", github.password = "bar") | |
animint2gist <- function(plot.list, out.dir = tempfile(), json.file = "plot.json", open.blocks = interactive()){ | |
gg2animint(plot.list, out.dir, json.file, open.browser = FALSE) | |
# use a flat file structure! |
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
// Define functions to render linked interactive plots using d3. | |
// Another script should define e.g. | |
// <script> | |
// var plot = new animint("#plot","path/to/plot.json"); | |
// </script> | |
// Constructor for animint Object. | |
var animint = function (to_select, json_file) { | |
var dirs = json_file.split("/"); | |
dirs.pop(); //if a directory path exists, remove the JSON file from dirs | |
var element = d3.select(to_select); |
OlderNewer