Skip to content

Instantly share code, notes, and snippets.

View Pakillo's full-sized avatar
🌳
Living the dream

Francisco Rodriguez-Sanchez Pakillo

🌳
Living the dream
View GitHub Profile
@Pakillo
Pakillo / Rmarkdown-fontsize.Rmd
Created January 22, 2015 22:32
Changing font sizes of HTML ouput in Rmarkdown
---
title: "Untitled"
author: "Francisco Rodriguez-Sanchez"
date: "Thursday, January 22, 2015"
output: html_document
---
<style type="text/css">
body, td {
@Pakillo
Pakillo / coauthor-networks.R
Created February 17, 2015 00:22
Coauthorsip networks
# Author network mapping for journal publications.
# By: Simon Goring (final code: 10/2/2013)
# https://downwithtime.wordpress.com/2013/02/10/on-blogging-and-collaboration/
library(bibtex)
library(network)
library(RColorBrewer)
# Read in the bibtex file
# You can export this file from your google scholar network.
@Pakillo
Pakillo / projections.R
Last active November 24, 2021 10:58
Geographical projections I often use
## Spatial reference systems I often use
## Source this gist from R:
# source("https://gist.githubusercontent.com/Pakillo/23212b72a02b9d524073/raw/b73b28354f61d381b5614a2254cf128b93e11c8a/projections.R")
# or using devtools:
# devtools::source_gist("https://gist.github.com/Pakillo/23212b72a02b9d524073")
# EPSG codes:
geo <- 4326 # Geographic, datum WGS84
laea.etrs89 <- 3035 # Lambert Azimuthal Equal Area - ETRS89
polygonizer <- function(x, outshape=NULL, gdalformat = 'ESRI Shapefile',
pypath=NULL, readpoly=TRUE, quietish=TRUE) {
# x: an R Raster layer, or the file path to a raster file recognised by GDAL
# outshape: the path to the output shapefile (if NULL, a temporary file will be created)
# gdalformat: the desired OGR vector format
# pypath: the path to gdal_polygonize.py (if NULL, an attempt will be made to determine the location
# readpoly: should the polygon shapefile be read back into R, and returned by this function? (logical)
# quietish: should (some) messages be suppressed? (logical)
if (isTRUE(readpoly)) require(rgdal)
if (is.null(pypath)) {
## Function to use GDAL to project coordinate reference system
# See http://www.gdal.org/gdalwarp.html for additional details
# `resampling` can be 'near' (nearest neighbour), 'bilinear', 'cubic', or
# 'lanczos' (Lanczos windowed sinc resampling).
# `extent` should be a bbox object or a vector of c(xmin, ymin, xmax, ymax)
# `of` is the output format (use GDAL short name as given by the name field of
# gdalDrivers(), or at http://www.gdal.org/formats_list.html)
# `extension` is the output extension corresponding to the primary file
# `ot` is the output type (see http://www.gdal.org/gdal_translate.html)
@Pakillo
Pakillo / iwanthue.R
Last active April 4, 2020 22:34 — forked from johnbaums/iwanthue.R
swatch <- function(x) {
# x: a vector of colours (hex, numeric, or string)
par(mai=c(0.2, max(strwidth(x, "inch") + 0.4, na.rm = TRUE), 0.2, 0.4))
barplot(rep(1, length(x)), col=rev(x), space = 0.1, axes=FALSE,
names.arg=rev(x), cex.names=0.8, horiz=T, las=1)
}
# Example:
# swatch(colours()[1:10])
# swatch(iwanthue(5))
@Pakillo
Pakillo / ggplot_resources.md
Last active October 17, 2022 04:38
ggplot2: tutorials and complementary packages
### Title: Back to basics: High quality plots using base R graphics
### An interactive tutorial for the Davis R Users Group meeting on April 24, 2015
###
### Date created: 20150418
### Last updated: 20150423
###
### Author: Michael Koontz
### Email: mikoontz@gmail.com
### Twitter: @michaeljkoontz
###