Skip to content

Instantly share code, notes, and snippets.

@etpinard
etpinard / plotly.py-custom-plotly.js-bundle
Last active February 1, 2021 11:06
Setup plotly.py with a custom plotly.js bundle
We couldn’t find that file to show.
@timelyportfolio
timelyportfolio / Readme.md
Last active April 26, 2016 08:10
R + d3.js Parallel Coordinates of partykit

Introduction

This d3.js parallel coordinates plot is another experiment in how we might use interactive plots in Javascript to represent a partykit / rpart object from R. The example builds on this d3.js collapsible tree plot. Eventually, it would be nice to combine the tree and parallel coordinates into a layout with synced interactivity.


### Almost No [`rCharts`](http://rcharts.io) Also, this is fairly different from most of my interactive plots from R in that it almost completely avoids [`rCharts`](http://rcharts.io) (almost because I did use its `publish` to make this gist). I chose to exclude `rCharts` for two reasons:
  1. demo how we can use htmltools to build html/js in R
  2. help users understand some of the things rCharts does f
iclass <- function(x) {
c(
if (is.matrix(x)) "matrix",
if (is.array(x) && !is.matrix(x)) "array",
if (is.double(x)) "double",
if (is.integer(x)) "integer",
mode(x)
)
}
@staltz
staltz / introrx.md
Last active April 15, 2024 10:24
The introduction to Reactive Programming you've been missing
@aammd
aammd / boot_reg.md
Last active August 31, 2017 03:12
bootstrapping regressions with `dplyr`.

Bootstrap confidence intervals for linear and nonlinear models

Another version of this gist with figures included is on Rpubs

Recently I was trying to put confidence intervals on a regression line, and I got some excellent advice from @davidjayharris on Twitter, who suggested the below method in an excellent

@woobe
woobe / README.md
Last active December 21, 2017 16:41
[rPlotter]: Customised Palette Experiments

Introduction

I created a function called "extract_colours()" in my "rPlotter" package. Using this function, any image in PNG, JPG, JPEG or TIFF format can be converted into a simple colour palette.

YET, this is my very first attempt, the colours are only sorted by alphabetical order at the moment. More work is needed to arrange colours based on colour theory and other factors.

Example 1a - R Logo R Logo

Output 1a

@ramnathv
ramnathv / README.md
Last active August 29, 2015 13:58
Building an rCharts Library

I very frequently get asked this question as to what is the best way to get started with building an rCharts library. While rCharts ships with its own bindings, I tend to see it more as a framework that allows one to seamlessly plug into other javascript visualization libraries, or even custom visualizations for that matter.

I will be writing a more detailed developer guide on how to build rCharts bindings for a library or chart of interest. For now, the knowledge is scattered across blog posts and my objective here is to consolidate them to provide some structure for anyone trying to build their own binding.

I will start with two posts of my own, where I deconstruct the process of going from a javascript visualization library to an rCharts binding. I take the example of uvCharts, which is a wrapper around d3.js, and explain how to go about integrating it within the rCharts framework.

  • [How rCharts Works -
@wch
wch / DESCRIPTION
Created March 17, 2014 21:14
conditionalPanel example for R Shiny
Type: Shiny
Title: conditionalPanel demo
License: MIT
Author: Winston Chang <winston@rstudio.com>
AuthorUrl: http://www.rstudio.com/
Tags: conditionalpanel
DisplayMode: Showcase
@jcheng5
jcheng5 / server.R
Created March 13, 2014 01:09
Progress example License: MIT
library(shinyIncubator)
shinyServer(function(input, output, session) {
output$plot <- renderPlot({
if (input$go == 0)
return()
# Wrap the entire expensive operation with withProgress
withProgress(session, {
setProgress(message = "Calculating, please wait",

Limitations of lapply()

lapply() is a really useful function but it has some limitations. For example, with lapply() there is no way to:

  • add new elements
  • remove existing elements
  • change the names of list elements

To overcome these problems we could create a variant of lapply() than I'm going to call fapply() (where f is for flexible). Rather than calling the supplied function with with an element of the list extract with [[, it will call it with a sub-list extracted with [.