Skip to content

Instantly share code, notes, and snippets.

Avatar

timelyportfolio timelyportfolio

View GitHub Profile
@timelyportfolio
timelyportfolio / .block
Last active Apr 5, 2021
geo pivot table with turf and leaflet
View .block
license: mit
@timelyportfolio
timelyportfolio / .block
Last active Feb 20, 2021
R base graphics with d3-annotation
View .block
license: mit
@timelyportfolio
timelyportfolio / Readme.md
Last active Feb 20, 2021
svg as reactiveValue in Shiny used with uiOutput
View Readme.md

Just playing around with svg from svglite, and I wondered if the svg output would work as reactiveValue in Shiny. Of course, it does. Then, I wanted to confirm that functions could be used for render*Output, and yes they can.

useful?

Is this useful? svg works really well in responsive contexts, so this might be helpful in that situation. Also, we could dynamically render svg spinners or animations on load or for other feedback. Let me know if you think of use cases.

functions for render*Output can help immensely.

library(htmltools)
@timelyportfolio
timelyportfolio / Readme.md
Created Apr 24, 2017
really dumb way to combine Vue and Shiny in R
View Readme.md

See the following for more examples combining R/Shiny and vuejs. All keep a global state store (not good practice) updated by shiny::sendCustomMessage().

  1. simple example
  2. more advanced d2b sunburst example

Code

Please note this is for illustration purposes only. vue is not needed at all, since all of this can easily be handled within Shiny.

@timelyportfolio
timelyportfolio / fat tails to the upside.r
Last active Jan 20, 2021
exceptional case of the Russell 2000
View fat tails to the upside.r
#explore exceptional case of the Russell 2000
require(quantmod)
require(PerformanceAnalytics)
require(xtsExtra)
getSymbols("^RUT", from = "1900-01-01")
getSymbols("^GSPC", from = "1900-01-01")
#do initial exploration of distribution
@timelyportfolio
timelyportfolio / README.md
Created Apr 19, 2016 — forked from jcheng5/README.md
Using arbitrary Leaflet plugins with Leaflet for R
View README.md

Using arbitrary Leaflet JS plugins with Leaflet for R

The Leaflet JS mapping library has lots of plugins available. The Leaflet package for R provides direct support for some, but far from all, of these plugins, by providing R functions for invoking the plugins.

If you as an R user find yourself wanting to use a Leaflet plugin that isn't directly supported in the R package, you can use the technique shown here to load the plugin yourself and invoke it using JS code.

@timelyportfolio
timelyportfolio / Readme.md
Last active Nov 5, 2020
R Shiny and Vue Simple Example
View Readme.md

Shiny == good & Vue == good | Shiny + Vue == good?

Shiny Shiny.shinyapp.$inputValues acts like a store of state. I thought it would be fun to let vuejs react to changes in Shiny input values. This example is intentionally very simple to hopefully self-explain.

vueR

I have assembled vueR package, like d3r and reactR, to offer helpers for vuejs. For this example please install vueR, or just add tags$script(src = "https://unpkg.com/vue@2.2.6") to the tagList().

devtools::install_github("timelyportfolio/vueR")`
@timelyportfolio
timelyportfolio / .block
Last active Oct 27, 2020
R leaflet tooltips with plotly htmlwidget
View .block
license: mit
@timelyportfolio
timelyportfolio / example.R
Created Sep 16, 2020
d3 calendar in R from observable/robservable
View example.R
# remotes::install_github("juba/robservable")
library(robservable)
# see entire notebook
robservable("@timelyportfolio/a-github-inspired-calendar")
# only see the chart
robservable(
"@timelyportfolio/a-github-inspired-calendar",
@timelyportfolio
timelyportfolio / nymap.R
Last active Aug 7, 2020
avoid data duplication in R leaflet
View nymap.R
library(tidycensus)
library(leaflet)
library(tidyr)
library(dplyr)
library(purrr)
library(sf)
library(htmlwidgets)
library(svglite)
ny_counties <- get_acs(