Skip to content

Instantly share code, notes, and snippets.

View csgillespie's full-sized avatar

Colin Gillespie csgillespie

View GitHub Profile
---
title: Checking Reveal.js
author: Ramnath Vaidyanathan
mode : selfcontained
framework: revealjs
hitheme : zenburn
revealjs:
theme: default
transition: none
center: "true"
@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)
## 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})
}
@csgillespie
csgillespie / RANDU.R
Created February 16, 2016 11:22
RANDU: the bad random number generator
N = 1000
randu = matrix(0, ncol=3, nrow=N)
##Simulate from the randu random number generator
new_z = 1
for(i in 1:N) {
new_x = (65539*new_z) %% 2^31
new_y = (65539*new_x) %% 2^31
new_z = (65539*new_y) %% 2^31
randu[i,] = c(x=new_x/2^31, y=new_y/2^31,
z=new_z/2^31)
<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é...",
@csgillespie
csgillespie / foundational-data-science.md
Last active October 31, 2019 16:55
Foundational data science with R

Software

Please make sure you are using a recent version of R (current version is 3.6.X) - the final digit is the minor version number. The essential numbers are the first two. You can check the version of R you are running via

R.version.string

Please install the latest version of RStudio (https://www.rstudio.com/products/rstudio/download/).

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)]