Skip to content

Instantly share code, notes, and snippets.

View csgillespie's full-sized avatar

Colin Gillespie csgillespie

View GitHub Profile
@csgillespie
csgillespie / index.html
Created August 27, 2014 18:07
Scatterplot
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
<link rel='stylesheet' href='http://nvd3.org/assets/css/nv.d3.css'>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js' type='text/javascript'></script>
<script src='http://d3js.org/d3.v3.min.js' type='text/javascript'></script>
<script src='http://timelyportfolio.github.io/rCharts_nvd3_tests/libraries/widgets/nvd3/js/nv.d3.min-new.js' type='text/javascript'></script>
0.026474
0.027401
0.033266
0.029264
0.117353
0.033074
0.024319
0.057596
0.024865
0.024960
@csgillespie
csgillespie / Makefile
Created October 9, 2015 08:35
Example Makefile used when dealing with Sweave
## $* = filename without extension
## $@ = the output file
## $< = the input file
.SUFFIXES: .tex .pdf .Rnw .R
MAIN = lecture
INCLUDES = chapter1 chapter2 chapter3
TEX = $(INCLUDES:=.tex)
RFILES = $(INCLUDES:=.R)
---
title: Checking Reveal.js
author: Ramnath Vaidyanathan
mode : selfcontained
framework: revealjs
hitheme : zenburn
revealjs:
theme: default
transition: none
center: "true"
## Save as Server.R
library("shiny")
#x = USArrests
#save(x, file="/tmp/tmp.RData")
server = function(input, output){
load("/tmp/tmp.RData")
output$table = output$table1 <- renderTable({x})
}
<div class="rmdnote">
Some text
```{r}
1+1
```
</div>
f = function(title="") {
set.seed(1)
par(mar=c(3,3,2,1), mgp=c(2,0.4,0), tck=-.01,
cex.axis=0.9, las=1)
plot(rnorm(100), rnorm(100), pch=21, bg="steelblue",
main=paste(title, "device"),
xlab="x-axis label", ylab="y-axis label",
xlim=c(-3,3), ylim=c(-3,3))
text(0,3,
"Le français, c'est façile: Règles, Liberté, Egalité, Fraternité...",
p_id = Sys.getpid()
cmd_mkl = paste("lsof -p", p_id, "| grep 'libmkl' | awk '{print $9}'")
out_mkl = try(system(cmd_mkl, intern = TRUE), silent = TRUE)
blas = out_mkl[grep("libmkl_core", out_mkl)]
lapack = out_mkl[grep("libmkl_intel_lp", out_mkl)]
@csgillespie
csgillespie / type.R
Created September 28, 2017 16:50
Testing rtypeform
api = rtypeform::get_api(api_key)
url = paste0("https://api.typeform.com/v1/form/", uid, "?key=", api)
## Form the REST URL & query
url = paste0(url, rtypeform:::get_order_by(NULL))
ua = httr::user_agent("https://github.com/csgillespie/rtypeform")
resp = httr::GET(url, ua)
cont = httr::content(resp, "text")
rtypeform:::check_api_response(resp)
@csgillespie
csgillespie / compare.R
Created September 29, 2017 12:37
Comparison of plotly and gpglotly
library(plotly)
library(reshape2)
compare_func_time = function(number = 1, N = 5000){
df = data.frame(matrix(nrow = N, ncol = 11, data = c(rnorm(10*N,10), rnorm(N,30,10))))
colnames(df) = paste0("dist", 1:11)
st1 = system.time({
replicate(number, {
l = list()