Skip to content

Instantly share code, notes, and snippets.

View simonohanlon101's full-sized avatar

Simon O'Hanlon simonohanlon101

  • Sainsburys PLC
  • London
View GitHub Profile
@simonohanlon101
simonohanlon101 / mbg_prediction.R
Created May 21, 2020 22:07
Script to predict onchocerciais prevalence in West Africa with geoRglm
# Title : Model-Based Geostatistical Mapping of Onchocerciais in West Africa
# Objective : Script to predict onchocerciais prevalence in West Africa
# Created by: sohanlon
options(echo=FALSE)
#
#
#/* PREAMBLE */
#
block reward_claimed max_reward lost_satoshis supply at block
124724 4998999999 5000000000 1000001 6236249.98999999
162705 4998300000 5000000000 1700000 8135299.97299999
162823 4999900000 5000000000 100000 8141199.97199999
162839 4998975200 5000000000 1024800 8141999.96175199
162952 4991535267 5000000000 8464733 8147649.87710466
162973 4989494061 5000000000 10505939 8148699.77204527
162980 4998820406 5000000000 1179594 8149049.76024933
162988 4999335613 5000000000 664387 8149449.75360546
162992 4995050000 5000000000 4950000 8149649.70410546
#include <Rcpp.h>
#include <string>
#include <sstream>
using namespace Rcpp;
//[[Rcpp::export]]
NumericMatrix expandR(CharacterVector x) {
int n = x.size();
@simonohanlon101
simonohanlon101 / West Africa Plot.R
Created February 5, 2013 15:09
Create plot of West Africa using ggplot2 and data from Natural Earth repository.
#Load relevant pacakges
library(ggplot2)
library(maptools)
library(rgeos)
library(plyr)
# Download and unzip the Natural Earth Country Polygon data
oldwd <- getwd()
tmp <- tempdir()
setwd(tmp)
@simonohanlon101
simonohanlon101 / StackOverflow - Q14708129.R
Created February 5, 2013 15:02
Returns column names of variables with 2nd and 3rd highest correlation with row variable
#==================================
#
# Answer to http://stackoverflow.com/q/14702714/1478381
# Using R to find correlation pairs
# Author: Simon O'Hanlon
# Date: 5th February 2013
#
#==================================
# Construct toy example of symmentrical matrix
@simonohanlon101
simonohanlon101 / PE-001.R
Last active December 3, 2018 06:01
Project Euler - problem 1
# Project Euler // Problem 1:
# Find the sum of all the multiples of 3 or 5 below 1000
x <- 1:999
sum( x[ x %% 5 == 0 | x %% 3 == 0 ] )
# Another solution (this is really bad R practice!) could be:
@simonohanlon101
simonohanlon101 / Hillshade DEM.R
Last active April 6, 2021 14:43
R Script to plot hillShade data over and DEM raster using ggplot2 Uses gridExtra package to push ggplot2 objects to particular viewports
# Script for question posted on Stack Overflow
# Load relevant libraries
library(ggplot2)
library(raster)
library(gridExtra)
vplayout <- function(x, y) {
viewport(layout.pos.row = x, layout.pos.col = y)
}