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); |
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
// 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
devtools::install_github("tdhock/animint", ref = "carson-test") | |
library(animint) | |
iris$id <- 1:nrow(iris) | |
viz <- list(petal=ggplot()+ | |
geom_point(aes(Petal.Width, Petal.Length, fill=Species, | |
clickSelects=id), data=iris), | |
sepal=ggplot()+ | |
geom_point(aes(Sepal.Width, Sepal.Length, fill=Species, | |
clickSelects=id), data=iris)) |
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
dat <- data.frame(x = 1:5, y = 1:5, p = 1:5, q = factor(1:5), | |
r = factor(1:5)) | |
p <- ggplot(dat, aes(x, y, colour = p, size = q, shape = r)) + geom_point() | |
p + scale_colour_continuous(guide = "colorbar") + guides(colour = "none") #no guide | |
p + scale_colour_continuous(guide = "none") + guides(colour = guide_colorbar()) #guide |
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","plot.json"); | |
// </script> | |
// Constructor for animint Object. | |
var animint = function (to_select, json_file) { | |
var element = d3.select(to_select); | |
this.element = element; | |
var Widgets = {}; |
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(dplyr) | |
library(pitchRx) | |
# This script requires pitchRx 1.5 | |
if (packageVersion("pitchRx") < 1.5) { devtools::install_github("cpsievert/pitchRx"); library(pitchRx) } | |
# Be sure to specify the *entire* path to your database | |
db.file <- "~/pitchfx/pitchRx.sqlite3" | |
stopifnot(file.exists(db.file)) | |
db <- src_sqlite(db.file) | |
update_db(db$con) |