Skip to content

Instantly share code, notes, and snippets.

View davidcoallier's full-sized avatar

David Coallier davidcoallier

View GitHub Profile
/*
SortTable
version 2
7th April 2007
Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/
Instructions:
Download this file
Add <script src="sorttable.js"></script> to your HTML
Add class="sortable" to any table you'd like to make sortable
https://usecanvas.com/

Mapping the Streets of Ireland With R and ggplot2

Earlier today an interesting article about plotting the streets of france appeared in my feed. What Simon does in his blog post is essentially read OSM street-lines-data for France and displays it in what I find to be a rather traditional and elegant way.

The first thing I immediately though of was: "I'd love to see this for Ireland". As an OSX user, it took a few tricks to get the article replicated for Ireland therefore I've decided to share my notes.

Should you wish to replicate this for your country, here are some notes I've taken.

Get The Data

Ingredients

Starter

  • Dill
  • 8 ounces of radish
  • 1/2 onion
  • 1/2 cup white vinegar,
  • 1/2 cup sugar, and
  • 1-1/2 teaspoons salt until sugar is dissolved.
cat(forecast_2w)
forecast_2w[1] == b_0 + (coeff * 12) // TRUE
forecast_2w[2] == b_0 + (coeff * 13) // TRUE
##
# Another helper for the laply
# Oh lazy dave when you'll re-read this code.
##
getText <- function(txt) {
txt$getText()
}
user created.at pages.visited
julie 2011-11-16 03:31:56 GMT 3
julie 2011-11-16 04:22:33 GMT 5
jack 2011-11-16 07:19:13 GMT 8
jack 2011-11-16 12:39:02 GMT 9
julie 2011-11-17 12:39:02 GMT 3

Load Data With Hmisc

Often times when working with data in R, you find yourself needing to summarise a data.frame by a column, a SELECT SUM(..) or SELECT COUNT(..) in MySQL if you will.

For instance, you may have a lot of page-visits to analyse and you aren't quite certain how to summarise some of that data using R.

Let's consider the following (trivial) dataset:

@davidcoallier
davidcoallier / language-popularity-on-stack-overflow.R
Created March 14, 2013 13:15
Script that looks up and plots the language popularity based on the stack-overflow tag-count.
require(RColorBrewer)
require(ggplot2)
require(scales)
# Thanks to drew conway for this handy function.
get.stack<-function(tok) {
# Must check for XML install, thanks onertipaday!
if (!require(XML)) install.packages('XML')
library(XML)
# Enter a SO tag as character string, and number of tags are returned
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
Year Divided Unified D Unified R
1938 10 21 15
1940 15 19 12
1942 9 17 20
1944 10 18 18
1946 8 17 21
1948 15 18 13
1950 15 15 16
1952 8 14 24
1954 16 16 14