Skip to content

Instantly share code, notes, and snippets.

View csgillespie's full-sized avatar

Colin Gillespie csgillespie

View GitHub Profile
@csgillespie
csgillespie / graphics.R
Last active November 12, 2022 14:31
Exploring R graphics
# Used in the blog post
# https://www.jumpingrivers.com/blog/r-graphics-cairo-png-pdf-saving/
library(ggplot2)
library(extrafont)
library(ragg)
library(Cairo)
extrafont::loadfonts()
set.seed(1)
@csgillespie
csgillespie / satRday.R
Last active April 9, 2019 20:44
SatRdays Twitter wars
library("rtweet")
library("tidyverse") # Don't judge me!
# Why is this not in tidyverse
# Can we start a petition?
library("lubridate")
# Notice the superior use of "=" over "<-"
get_tweets = function(q, n = 1000, include_rts = TRUE) {
search_tweets(q = q, n = n,
@csgillespie
csgillespie / README.md
Last active August 24, 2022 16:26
Getting the most out of Git

Getting the most out of Git

This GitHub gist contains instructions for the R, git & travis tutorial.

Assumed knowledge

Partipants must be familar with

@csgillespie
csgillespie / odsc-pre-req.md
Last active August 19, 2020 13:58
Prerequisites for ODSC

R for Python Programmers

This course is suitable for anyone with a some previous background in programming (not necessarily Python).

Software

R

Please make sure you a using a recent version of R (at least 3.6.X) - the final digit is the minor version number. The essential numbers are the first two.

@csgillespie
csgillespie / odsc-east.md
Last active April 9, 2020 19:16
Pre-requisites for ODSC
title output
Tidyverse prerequisites (ODSC)
html_notebook

Software

Please make sure you a using a recent version of R (at least 3.4.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

@csgillespie
csgillespie / toeplitz.R
Created October 27, 2017 11:41
Slow down
##R version 3.4.2 (2017-09-28)
##Platform: x86_64-pc-linux-gnu (64-bit)
##Running under: Ubuntu 16.04.3 LTS
bm_prog_toeplitz = function() {
N = 3000
ans = rep(0, N*N)
dim(ans) = c(N, N)
system.time({
for (j in 1:N) {
@csgillespie
csgillespie / Setup.md
Last active October 11, 2017 21:35
odsc

Overview

This session will be a mixture of lectures and short practical sessions using R.

Software

Please make sure you are using the latest version of R (current version is 3.4.1) - 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

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