Instantly share code, notes, and snippets.

# timelyportfolio timelyportfolio

Last active February 19, 2023 23:01
3d yield curve with Plotly in R

Nowhere near as spectacular as the Upshot/New York Times 3d yield curve by Amanda Cox and Gregor Aisch, but not bad at all for a couple of lines of R code with the plotly htmlwidget.

library(plotly)
library(dplyr)
library(tidyr)
library(purrr)
library(quantmod)
library(magrittr)
Last active September 27, 2022 13:04
vega-lite changing bar size and spacing
Last active September 12, 2022 18:26
experiment with vega formula transform and new zip functionality

### Vega Experiments with Stats and Formula Transform and New Zip

Using the barley.json example from the vega package, I wanted to try to add plots with x as

1. Yield Difference From Site Mean
2. Yield Difference From Aggregate Mean

Please do not replicate, since I'm guessing I'm performing this ugly hack instead of the more elegant preferred method that I have overlooked. New projects are like puzzles, and I'm still a long way from completing this one.

Created April 19, 2016 18:11 — forked from jcheng5/README.md
Using arbitrary Leaflet plugins with Leaflet for R

## 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.

Last active July 11, 2022 06:14
d3 hierarchies in R

Built with blockbuilder.org

It seems that working with d3.js hierarchies in R causes much consternation. Here is a quick little demonstration of working with the flare.json hierarchy often used in d3, processing, and Protovis. data.tree eases the pain considerably. I also include the purrr code for those interested in this library and/or some hierarchy recursion in R.

# work through d3 hierarchies in R
#  using data.tree and dplyr
#  on the commmonly used flare.json
Last active February 9, 2022 03:59
View example.R
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(rhandsontable) library(htmltools) browsable(tagList( rhandsontable( data = mtcars, rowHeaders = NULL, # see http://jsfiddle.net/pn3rv48p/ for another example with afterGetColHeader afterGetColHeader = htmlwidgets::JS(htmltools::HTML( sprintf(
Last active December 10, 2021 02:30
vue and networkD3 in R
View .block
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
Last active September 28, 2021 13:28
trelliscope and sparkline example
View .block
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
Last active September 17, 2021 17:16
summary widget with flexdashboard valueBox
View example.Rmd
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: "Example of filtered values boxes" output: flexdashboard::flex_dashboard: orientation: rows vertical_layout: fill mathjax: null --- {r setup, include=FALSE}
Last active August 15, 2021 17:49
R visualization of arules with arulesViz + igraph + visNetwork
## Interactive arules with arulesViz and visNetwork
In response to visNetwork issue #6, here is some code to demonstrate how we might interactively visualize an arules object in R using the new htmlwidget visNetwork. Fortunately, arulesViz has already done a lot of the plumbing for us.
# visNetwork view of arules
library(visNetwork)`