This file contains hidden or 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
accumulate_by <- function(dat, var, showLastFirst = FALSE) { | |
var <- lazyeval::f_eval(var, dat) | |
lvls <- plotly:::getLevels(var) | |
dats <- lapply(seq_along(lvls), function(x) { | |
cbind(dat[var %in% lvls[seq(1, x)], ], frame = lvls[[x]]) | |
}) | |
if (showLastFirst) { | |
lastFrame <- dats[[length(dats)]] | |
# you will likely have to fiddle with this value | |
lastFrame$frame <- 0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
# install.packages("plotly") | |
library(plotly) | |
library(htmlwidgets) | |
# grab some fake data from manhattanly | |
# note this is a data.frame! | |
# you can convert a matrix to a data frame with as.data.frame() | |
download.file("https://github.com/sahirbhatnagar/manhattanly/raw/master/data/HapMap.rda", "HapMap.rda") | |
load("HapMap.rda") |
This file contains hidden or 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(jsonlite) | |
txt <- '{ | |
"points": [{ | |
"curveNumber": 0, | |
"text": "a", | |
"pointNumber": 0, | |
"customdata": "c.a", | |
"y": 4, | |
"x": 1 |
This file contains hidden or 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(tidyr) | |
library(readr) | |
# For other measures, see http://ghdx.healthdata.org/us-data | |
# TODO: do this on the county level for more interesting data, like this post - https://fivethirtyeight.com/features/mortality-black-belt/ | |
obesity <- read_csv("http://ghdx.healthdata.org/sites/default/files/record-attached-files/IHME_USA_OBESITY_PHYSICAL_ACTIVITY_2001_2011.csv") | |
# reshape data so value tracks | |
ob <- obesity %>% |
This file contains hidden or 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(plotly) | |
# I keep a collection of my (plotly and non-plotly) apps here | |
# https://github.com/cpsievert/apps | |
runGitHub("apps", "cpsievert", subdir = "shiny/apps/plotlyAg") | |
browseURL("https://github.com/cpsievert/apps/blob/master/shiny/apps/plotlyAg/app.R") | |
# The plotly package ships with some rmarkdown/shiny examples | |
browseURL("https://github.com/ropensci/plotly/tree/master/inst/examples") |
This file contains hidden or 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
{"x":{"data":[{"orientation":"v","width":[0.310344827586207,0.310344827586207,0.310344827586207,0.310344827586207,0.310344827586206,0.310344827586207,0.310344827586206,0.310344827586206,0.310344827586206,0.310344827586206,0.310344827586206,0.310344827586206,0.310344827586206,0.310344827586206,0.310344827586206,0.310344827586206,0.310344827586206,0.310344827586206,0.310344827586206,0.310344827586206,0.310344827586206,0.310344827586206,0.310344827586206,0.310344827586207,0.310344827586206,0.310344827586206,0.310344827586206,0.310344827586206,0.310344827586206,0.310344827586206],"base":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"x":[0.931034482758621,1.24137931034483,1.55172413793103,1.86206896551724,2.17241379310345,2.48275862068966,2.79310344827586,3.10344827586207,3.41379310344828,3.72413793103448,4.03448275862069,4.3448275862069,4.6551724137931,4.96551724137931,5.27586206896552,5.58620689655172,5.89655172413793,6.20689655172414,6.51724137931035,6.82758620689655,7.13793103448276,7.448275862 |
This file contains hidden or 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(plotly) | |
plot_ly( | |
type = 'sankey', | |
node = list( | |
label = c("a","b", "c", "d", "e", "f", "g", "h"), | |
color = c("black","black","black","black","black","black", | |
"black","black"), | |
pad = 15, | |
thickness = 15, |
This file contains hidden or 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(grid) | |
(a <- arrow()) | |
#> $angle | |
#> [1] 30 | |
#> | |
#> $length | |
#> [1] 0.25inches | |
#> | |
#> $ends | |
#> [1] 2 |
This file contains hidden or 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(plotly) | |
library(htmlwidgets) | |
plot_ly(x = c(1, 2), y = c(1, 2)) %>% | |
onRender( | |
'function(el, x) { | |
setTimeout(function() { | |
var gd = document.getElementById(el.id); | |
var obj = {"mode": "markers"}; | |
for (var i = 0; i < 10; i++) { |