Skip to content

Instantly share code, notes, and snippets.

🤔
Programming programs that others use to program programs that write programs

Carson Sievert cpsievert

🤔
Programming programs that others use to program programs that write programs
Block or report user

Report or block cpsievert

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View flex-shiny-session.Rmd
---
title: "Untitled"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
View proxy-dashboard.Rmd
---
title: "dash"
output: flexdashboard::flex_dashboard
runtime: shiny_prerendered
---
```{r setup, include=FALSE}
library(tidyverse)
library(plotly)
View plotly-proxy-rmd.Rmd
---
title: "Untitled"
output: html_document
runtime: shiny_prerendered
---
```{r}
library(plotly)
plotlyOutput("p")
```
View leaflet-proxy-rmd.Rmd
---
title: "Untitled"
output: html_document
runtime: shiny_prerendered
---
```{r}
library(leaflet)
leafletOutput("map")
```
View index.html
<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],
@cpsievert
cpsievert / line-on-brush.R
Created Feb 9, 2018
Draw line shapes outlining brush
View line-on-brush.R
library(plotly)
library(crosstalk)
library(htmlwidgets)
mtcars %>%
SharedData$new() %>%
plot_ly(x = ~wt, y = ~mpg) %>%
highlight("plotly_selected", dynamic = TRUE) %>%
onRender(
"function(el, x) {
@cpsievert
cpsievert / cumulative-last-first.R
Created Feb 9, 2018
Cumulative animation where last frame is shown first
View cumulative-last-first.R
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
View counties.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cpsievert
cpsievert / volcano-plot-snp.R
Last active Feb 9, 2018
Volcano plot with the ability to query snp codes
View volcano-plot-snp.R
# 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")
@cpsievert
cpsievert / simplify.R
Created Dec 22, 2017
fromJSON simplification
View simplify.R
library(jsonlite)
txt <- '{
"points": [{
"curveNumber": 0,
"text": "a",
"pointNumber": 0,
"customdata": "c.a",
"y": 4,
"x": 1
You can’t perform that action at this time.