Skip to content

Instantly share code, notes, and snippets.

View pboesu's full-sized avatar

Philipp Boersch-Supan pboesu

View GitHub Profile
require(quantmod)
require(fAssets)
#get asian currency data from the FED FRED data series
getSymbols("DEXKOUS",src="FRED") #load Korea
getSymbols("DEXMAUS",src="FRED") #load Malaysia
getSymbols("DEXSIUS",src="FRED") #load Singapore
getSymbols("DEXTAUS",src="FRED") #load Taiwan
getSymbols("DEXCHUS",src="FRED") #load China
getSymbols("DEXJPUS",src="FRED") #load Japan
### Title: Back to basics: High quality plots using base R graphics
### An interactive tutorial for the Davis R Users Group meeting on April 24, 2015
###
### Date created: 20150418
### Last updated: 20150423
###
### Author: Michael Koontz
### Email: mikoontz@gmail.com
### Twitter: @michaeljkoontz
###
@pboesu
pboesu / regex
Last active February 25, 2016 22:25
helpful regex
\[[^\]]+\] #everything within square brackets http://regexr.com/3csqg
https://twitter.com/OttawaFieldNat/status/409695678781091840
@pboesu
pboesu / mtcars-cat.R
Last active November 18, 2016 10:47 — forked from dill/mtcars-cat.R
categorical emojis -- like this Mark?
library(emoGG)
library(ggplot2)
#use subsetting to display different emojis for different factor levels
ggplot(mtcars, aes(wt, mpg))+
geom_emoji(data = mtcars[mtcars$am==1, ], emoji = "1f697") +
geom_emoji(data = mtcars[mtcars$am==0, ], emoji = "1f68c")
@pboesu
pboesu / antipodes.sh
Last active December 8, 2016 20:26
GMT scripts for Enderby Trip visualisation
#!/bin/bash
# This map is a quick and dirty adaptation of GMT EXAMPLE 25
# (using GMT 5.4.0_r17345)
# Purpose: Display distribution of antipode types around NZ
# GMT modules: gmtset, grdlandmask, grdmath, grd2xyz, gmtmath, grdimage, pscoast, pslegend
# Unix progs: cat
#
# Create D minutes global grid with -1 over oceans and +1 over land
D=10
gmt grdlandmask -Rg -I${D}m -Dc -A500 -N-1/1/1/1/1 -r -Gwetdry.nc
@pboesu
pboesu / Hytool_example
Created July 12, 2017 20:17
"Getting started" example run on MATLAB R2014b
Warning: Function cummax has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.
>> edit ths_ds1.dat
>> [t,s]=ldf('ths_ds1.dat');
clf
plot(t,s,'o')
xlabel('Time in seconds')
ylabel('Drawdown in meters')
title('The Fetter data set')
>> diagnostic(t,s)
Attempted to access Dk(:,2); index out of bounds because
gc()
#devtools::install_github("pboesu/rucrdtw", ref = "expose_distance_calculations")
library(rucrdtw)
set.seed(12444)
x = rnorm(10^4)
y = rnorm(10^4)
gctorture(on = TRUE)
for (i in 1:(2*10^3)) {
@pboesu
pboesu / academic_moves.Rmd
Created February 17, 2018 16:00
Academic moves
---
title: "Academic moves"
author: "Philipp Boersch-Supan"
date: "2018-02-17"
output:
html_document:
keep_md: yes
---
@pboesu
pboesu / 20180807jennis_challenge.R
Last active August 7, 2018 11:28
Jenni's coding challenge
require(dplyr)
nuts1 <- readr::read_csv('NUTS1_kmsq.csv')
nuts1 %>% group_by(ONEKMREF) %>% summarise(biggest_area = max(kmsq_Area), biggest_area_index = which.max(kmsq_Area), biggest_area_name = Region_name[biggest_area_index] ) -> solution_df
#check for areas with multiple regions
nuts1 %>% group_by(ONEKMREF) %>% summarise(n_rows = n()) %>% arrange(desc(n_rows)) %>% head()