library(sf)
#> Linking to GEOS 3.6.2, GDAL 2.2.3, proj.4 5.0.0
library(rmapshaper)
library(geojsonio)
#>
#> Attaching package: 'geojsonio'
#> The following object is masked from 'package:base':
#>
#> pretty
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------------------ | |
# PostgreSQL configuration file customizations | |
# ------------------------------------------ | |
#------------------------------------------------------------------------------ | |
# CONNECTIONS AND AUTHENTICATION | |
#------------------------------------------------------------------------------ | |
# - Connection Settings - |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
# preview a file that would be created by ggsave() | |
ggpreview <- function(...) { | |
fname <- tempfile(fileext = ".png") | |
ggsave(filename = fname, ...) | |
system2("open", fname) | |
invisible(NULL) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/aa049a47b218fda30f9a4a454119ae067a02cf50/Formula/postgis.rb | |
#pg_config --pkglibdir is useful for finding your $libdir | |
cp -a /usr/local/share/postgresql/extension/postgis* /usr/local/Cellar/[email protected]/9.6.5/share/[email protected]/extension/ | |
cp -a /usr/local/lib/postgresql/postgis-2.3.so /usr/local/Cellar/[email protected]/9.6.5/lib/postgis-2.3 | |
cp -a /usr/local/lib/postgresql/rtpostgis-2.3.so /usr/local/Cellar/[email protected]/9.6.5/lib/ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get update | |
sudo apt-get upgrade | |
# gdal | |
sudo add-apt-repository ppa:ubuntugis/ppa | |
sudo apt-get update | |
sudo apt-get install gdal-bin libgdal-dev | |
# postgres/postgis | |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## GOAL: | |
## re-create a figure similar to Fig. 2 in Wilson et al. (2018), | |
## Nature 554: 183-188. Available from: | |
## https://www.nature.com/articles/nature25479#s1 | |
## | |
## combines a boxplot (or violin) with the raw data, by splitting each | |
## category location in two (box on left, raw data on right) | |
# initial set-up ---------------------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"editor.fontFamily": "'Operator Mono Lig', Iosevka, Menlo, Monaco, 'Courier New', monospace", | |
"editor.fontLigatures": true, | |
"editor.fontSize": 14, | |
"editor.tabSize": 2, | |
"editor.wordWrap": "on", | |
"r.rterm.mac" : "/usr/local/bin/rtichoke", | |
"r.rterm.option" : [], | |
"r.lintr.enabled": false, | |
"terminal.external.osxExec": "iTerm.app", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
camel_to_snake <- function(x, case = c("lower", "upper")) { | |
case <- match.arg(case) | |
case_fun <- switch(case, lower = tolower, upper = toupper) | |
case_fun(gsub("([a-z0-9])([A-Z]+)", "\\1_\\2", x)) | |
} | |
snakeToCamel <- function(x) { | |
x <- tolower(x) | |
gsub("([a-z0-9]+)_([a-z0-9])", "\\1\\U\\2\\E", x, perl = TRUE) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TODAY=`date +%Y-%m-%d` | |
TODAY_MD=`date +%B\ %d,\ %Y` | |
YEAR=`date +%Y` | |
PACKAGENAME=$1 | |
## | |
## CHANGE ME!!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Plot a ggmap object when you will be adding geom_sf() layers | |
#' | |
#' This is a wrapper around [ggmap::ggmap()], that transforms the bounding | |
#' box of the ggmap object to epsg:3857, which is what the underlying | |
#' data is in. This allows you to add `geom_sf()` layers with a crs | |
#' of epsg:3857 and have them line up properly. | |
#' | |
#' See [this stackoverflow question](https://stackoverflow.com/q/47749078/1736291) | |
#' | |
#' |