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
--- | |
title: "dash" | |
output: flexdashboard::flex_dashboard | |
runtime: shiny_prerendered | |
--- | |
```{r setup, include=FALSE} | |
library(tidyverse) | |
library(plotly) |
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
--- | |
title: "Untitled" | |
output: html_document | |
runtime: shiny_prerendered | |
--- | |
```{r} | |
library(plotly) | |
plotlyOutput("p") | |
``` |
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
--- | |
title: "Untitled" | |
output: html_document | |
runtime: shiny_prerendered | |
--- | |
```{r} | |
library(leaflet) | |
leafletOutput("map") | |
``` |
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
<head> | |
<!-- Plotly.js --> | |
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script> | |
</head> | |
<body> | |
<div id="graph"></div> | |
<script> | |
var dat = [{ | |
"x": [1,2,3,4,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(plotly) | |
library(crosstalk) | |
library(htmlwidgets) | |
mtcars %>% | |
SharedData$new() %>% | |
plot_ly(x = ~wt, y = ~mpg) %>% | |
highlight("plotly_selected", dynamic = TRUE) %>% | |
onRender( | |
"function(el, x) { |
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
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 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# 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 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 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 %>% |