Skip to content

Instantly share code, notes, and snippets.

View SimonGoring's full-sized avatar

Simon SimonGoring

View GitHub Profile
@SimonGoring
SimonGoring / 01_SGoringPAGES_ECR.md
Last active January 29, 2019 00:00
Getting ready for the PAGES ECR Webinar

Getting From There to Here

This webinar is set up as a "storytelling" session, about how I work through my projects that are intended for publication. In practice this is now how I manage most of my projects that involve some element of data exploration and collaboration. I will be live-coding during the presentation and intend to do so in a way that will allow people to follow along to some degree.

The webinar will be recorded and so people should not feel obligated to code along, or to keep up. If you would like to follow along, or revisit the webinar at a later date, these are the programs and R packages that you will need.

Important Links

@SimonGoring
SimonGoring / installLibs.sh
Last active January 2, 2019 20:37
Recursively searches R and Rmd files in a directory to install all required packages using R.
#!/bin/bash
# This scrips is described in more detail at http://www.goring.org/resources/regex_bash_libraries.html
rinstall=0
while getopts "i" OPTION
do
case $OPTION in
i)
echo Running installLib with the option to install packages.
@SimonGoring
SimonGoring / DataTypesinPython.ipynb
Created October 2, 2018 04:54
Loading yaml, csv, json and json-ld files in Python.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SimonGoring
SimonGoring / builddb.py
Last active September 28, 2018 05:15
A script to build the database from the raw files.
""" Import libraries and create the connection. If the connection fails check the JSON file. """
import json
import csv
import re
import psycopg2
# Set to True if we want to delete the whole database as it runs:
dropall = True
@SimonGoring
SimonGoring / onlinesales.ipynb
Created September 20, 2018 06:34
Modified ipython notebook with new data and table definitions
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SimonGoring
SimonGoring / db_connect.json
Last active September 18, 2018 05:35
IPython Notebook for BAIT Group Project
{
"host": "localhost",
"port": 5432,
"database": "yourdatabase",
"user": "postgres",
"password": "postgres"
}
@SimonGoring
SimonGoring / neotomav2fagus.R
Created May 16, 2018 16:25
Obtain data from the v2.0 Neotoma data API and plot it using R.
# Use the newer Neotoma API to pull sites with Fagus into a map from a JSON response.
# Used as part of the Data Demo Derby (hosted by EarthRates)
small_occ <- httr::GET('http://api-dev.neotomadb.org/v2.0/data/occurrence/?taxonname=Fagus&limit=5000')
small_content <- httr::content(small_occ)
library(dplyr)
site_table <- small_content$data %>%
@SimonGoring
SimonGoring / neotoma_and_bacon
Last active August 14, 2017 18:14
A quick example to load a data file from Neotoma and then run Bacon.
# This needs to run in the directory in which you have Bacon installed.
# If you do not currently have the `neotoma` package installed then uncomment
# and run the following code. Right now you will need to install the package from GitHub
# because our latest bug fixes haven't been pushed up into CRAN.
#
# install.packages('devtools')
# library(devtools)
# install_github('ropensci/neotoma')
#
# The Neotoma package is described more fully here:
@SimonGoring
SimonGoring / neotoma_us_lake_sizes.R
Last active August 7, 2017 22:52
Extract lake sizes from the National Hydrology Database for all US Neotoma pollen sites.
# This script starts from scratch:
library(rgdal)
library(neotoma)
library(dplyr)
library(purrr)
library(sp)
library(datasets)
library(sf)
@SimonGoring
SimonGoring / rstudio-backtrace.txt
Created April 18, 2017 17:51
RStudio backtrace - Crash on file open.
RStudio Version: 1.0.136
> print(sessionInfo())
R version 3.3.3 (2017-03-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.2 LTS
locale:
[1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8