Skip to content

Instantly share code, notes, and snippets.

View malcolmbarrett's full-sized avatar

Malcolm Barrett malcolmbarrett

View GitHub Profile
library(shiny)
library(ggplot2)
ui <- function(request){
tagList(
h2("Click on the plot to download it"),
tags$button(
"Click here to download the plot",
onclick = 'var a = document.createElement("a"); a.href = $("#plop").find("img").attr("src"); a.download = "Image.png"; a.click(); '
),
plotOutput("plop")
library(tidyverse)
library(ggdag)
library(ggraph)

theory_dag <- dagify(AE ~ PF,
                     PF ~ IC + RC,
                     FIC ~ AE,
                     labels = c("AE" = "Advocacy\neffects", 
                                "PF" = "Programmatic\nflexibility",
@kevinushey
kevinushey / apply_mean.cpp
Last active April 14, 2019 06:23
row, column-wise operations in Rcpp
// the column-wise implementation is just as fast as colMeans,
// but the row-wise operation is not quite as fast as rowMeans.
// can I do better?
#include <Rcpp.h>
using namespace Rcpp;
template <class T>
inline double do_mean( T& x ) {