I hereby claim:
- I am jimjam-slam on github.
- I am rensa (https://keybase.io/rensa) on keybase.
- I have a public key whose fingerprint is 0A48 7DAE 8103 D2B4 6C50 1815 AF35 3FD1 0B42 DABB
To claim this, I am signing this object:
| # james goldie, climate change research centre, unsw, dec 2015 | |
| # run.time: returns the time elapsed since this script was | |
| # sourced in sensible units as a string ('**h**m**s') | |
| script.start.time = Sys.time() | |
| run.time <- function() | |
| { | |
| now = Sys.time() | |
| return(paste0( | |
| as.integer(difftime(now, script.start.time, units = 'hours')), |
| # count_leap_days: returns an integer for the number of leap days between a | |
| # vector of dates and a constant epoch | |
| count_leap_days <- function(dates, epoch = ymd('1850-01-01'), proleptic = FALSE) | |
| { | |
| require(lubridate) | |
| # check input | |
| if (!is(epoch, 'Date') | !is(dates, 'Date')) | |
| { | |
| stop('count_leap_days: both arguments must be Date objects.') |
I hereby claim:
To claim this, I am signing this object:
| # these two functions, iso_to_emoji_unicode and iso_to_emoji_ascii, convert two-letter iso country codes | |
| # (eg. australia = AU) to the unicode control sequences used for their flag emoji. the _unicode function | |
| # outputs the actual unicode characters (printed in R in ascii but stored in ascii); the _ascii function | |
| # outputs an ascii representation (with the argument ligature_sep in between the two strings). | |
| library(stringr) | |
| # iso_to_emoji_unicode: for a vector of two-letter iso codes, returns a | |
| # corresponding vector of two-character unicode control sequences. | |
| # (nb: R prints them in ascii, but they're really stored as unicode characters) | |
| # great for use with countrycode and emojifont! |
| library(XML) | |
| for (file in list.files(pattern = glob2rx('*.svg'))) | |
| { | |
| message('Processing ', file) | |
| flag = xmlParse(file) | |
| circle_node = newXMLNode('circle', | |
| attrs = c( | |
| 'fill' = 'none', | |
| 'stroke' = '#333', |
| <div class="publist"> | |
| <ul> | |
| {% for post in site.categories.science %} | |
| {% if post.work-type == 'Paper' %} | |
| <li> | |
| <a href="{% if post.ref-doi %}http://dx.doi.org/{{ post.ref-doi }}{% else %}{{ post.url | prepend: site.baseurl }}{% endif %}"><h2>{{ post.ref-authors }} ({{ post.ref-year }}).</h2></a> | |
| <p>{{ post.ref-title }}. <em>{{ post.ref-journal}}</em>{% if post.ref-vol %}, {{ post.ref-vol }}{% endif %}. <a href="http://dx.doi.org/{{ post.ref-doi }}">doi: {{ post.ref-doi }}</a></p> | |
| </li> | |
| {% endif %} | |
| {% endfor %} |
| { | |
| // See https://go.microsoft.com/fwlink/?LinkId=733558 | |
| // for the documentation about the tasks.json format | |
| "version": "2.0.0", | |
| "tasks": [ | |
| { | |
| "label": "Knit bookdown project", | |
| "type": "shell", | |
| "command": "/usr/local/bin/RScript -e 'setwd(\"index\"); bookdown::render_book(\"index.rmd\"); setwd(\"..\");'", | |
| "windows": { |
| { | |
| // Snippets for talking to yourself | |
| "TK (citation needed)": { | |
| "prefix": "tkcite", | |
| "body": "_(**TKTK** - citation needed)_", | |
| "description": "Add a note to yourself to cite this later." | |
| }, | |
| "TK": { | |
| "prefix": "tktk", | |
| "body": "_(**TKTK** - blah blah blah)_", |
| library(tidyverse) | |
| library(ggrepel) # substitude geom_text for geom_text_repel if you don't want to bother with this! | |
| mydata = | |
| data_frame( | |
| x = 1:10, | |
| y = rnorm(10), | |
| name = c('Apple', 'Banana', 'Kiwi', 'Orange', 'Watermelon', | |
| 'Grapes', 'Pear', 'Cantelope', 'Tomato', 'Satsauma')) %>% | |
| mutate( |
| # gridSVG::grid.garnish can be used to add SVG attributes to elements of a plot! | |
| # we don't even need to do it one at a time: with the option `group = FALSE`, we | |
| # can give it a vector of values for an attribute and garnish an entire geom at | |
| # once. the only rub is that sometimes ggplot2 shuffles your data around when | |
| # plotting it. we need to check how the data was reordered, and arrange our | |
| # original data to match, before we send it to grid.garnish. | |
| library(tidyverse) | |
| library(magrittr) | |
| library(grid) |