Skip to content

Instantly share code, notes, and snippets.

View timelyportfolio's full-sized avatar

timelyportfolio timelyportfolio

View GitHub Profile
@AlbertRapp
AlbertRapp / stacked_bar_plot_alternative.qmd
Last active June 27, 2023 13:01
How to split bars instead of stacking them
---
output: html_document
editor_options:
chunk_output_type: console
---
```{r}
setwd(here::here('stacked_bar_alternative/'))
camcorder::gg_record(
dir = 'img',
@jcheng5
jcheng5 / README.md
Last active February 2, 2024 10:10
Accepting POST requests from Shiny

Accepting POST requests from Shiny

(This post was motivated by a talk by @jnolis at CascadiaRConf 2021)

Recent versions of Shiny have an undocumented feature for handling POST requests that are not associated with any specific Shiny session. (Note that this functionality is missing our normal level of polish; it's a fairly low-level hook that I needed to make some things possible, but doesn't make anything easy.)

In a nutshell, it works by replacing your traditional ui object with a function(req), and then marking that function with an attribute indicating that it knows how to handle both GET and POST:

library(shiny)
library(leaflet)
map = leaflet() %>%
addTiles()
m = htmlwidgets::onRender(
map,
jsCode = htmlwidgets::JS(
"function(el,x,data){
var map = this;
# process:
# - make a new branch: git checkout -b some-branch
# - run this script: Rscript path/to/package_strip_urls.R
# - update manual files and make sure package passes check
# - submit to cran
# - after accepted on cran - delete some-branch
have_pkg <- function(pkg) {
if (!requireNamespace(pkg, quietly = TRUE)) stop("need package ", pkg)
}
@texodus
texodus / .block
Last active August 17, 2020 03:44
regular-table / Spreadsheet
license: apache-2.0
@texodus
texodus / .block
Last active August 17, 2020 03:46
regular-table / File Browser
license: apache-2.0
@texodus
texodus / .block
Last active August 17, 2020 03:54
regular-table / Perspective
license: apache-2.0
@texodus
texodus / .block
Last active August 17, 2020 03:45
regular-table / Canvas Data Model
license: apache-2.0
height: 800
@texodus
texodus / .block
Last active August 11, 2022 02:28
Perspective / Superstore Example
license: apache-2.0
@texodus
texodus / .block
Last active August 10, 2022 19:08
Perspective Datagrid / Custom Style Example
license: apache-2.0