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 / gist:02bc9c52246559d266ff5d5ef6d374b8
Last active October 7, 2020 12:59
How to hide some slides in Rmarkdown-generated beamer PDF presentation
https://stackoverflow.com/a/58679929
See also
http://latex-beamer-class.10966.n7.nabble.com/Hiding-frames-td907.html
https://tex.stackexchange.com/questions/200151/remove-frame-from-presentation
https://tex.stackexchange.com/questions/200151/remove-frame-from-presentation
@Pakillo
Pakillo / diverge0.R
Created December 12, 2019 13:44 — forked from johnbaums/diverge0.R
Plot a rasterVis::levelplot with a colour ramp diverging around zero
diverge0 <- function(p, ramp) {
# p: a trellis object resulting from rasterVis::levelplot
# ramp: the name of an RColorBrewer palette (as character), a character
# vector of colour names to interpolate, or a colorRampPalette.
require(RColorBrewer)
require(rasterVis)
if(length(ramp)==1 && is.character(ramp) && ramp %in%
row.names(brewer.pal.info)) {
ramp <- suppressWarnings(colorRampPalette(brewer.pal(11, ramp)))
} else if(length(ramp) > 1 && is.character(ramp) && all(ramp %in% colors())) {
@Pakillo
Pakillo / Sentinel2-repaso.R
Created October 23, 2019 07:04
Sentinel-2 repaso
## Working with Sentinel-2 bands in R
# Crear proyecto de RStudio
## Cargar paquetes necesarios
library(raster)
@Pakillo
Pakillo / Sentinel2-intro.R
Created October 23, 2019 07:04
Sentinel2-intro.R
## Working with Sentinel-2 bands in R
## Primeros pasos
# - Crear proyecto de RStudio
#
# - Guardar capas (ZIP) en la misma carpeta
@Pakillo
Pakillo / cc_paleotemp.R
Created September 3, 2018 18:25
Figure of Cenozoic (last 66 million years) and future global temperatures expected with climate change
library(ggplot2)
library(cowplot)
library(latex2exp)
#### PALEOTEMPERATURES ####
## Data from Hansen: http://www.columbia.edu/~jeh1/mailings/2012/20120508_ClimateSensitivity.pdf
## Available here: http://www.columbia.edu/~mhs119/Sensitivity+SL+CO2/Table.txt
@Pakillo
Pakillo / repromap.R
Last active March 21, 2018 19:01
another reproducible map with Rstats
library(sf)
library(ggspatial)
library(ggthemes)
coast <- rnaturalearth::ne_coastline(scale = "small", returnclass = "sp")
forests <- st_read("data/forestmap/cfc_gen.shp")
forest.redux <- rmapshaper::ms_simplify(forests)
forest.redux.sp <- as(forest.redux, "Spatial")
@Pakillo
Pakillo / Worldclim_Precipitation_Uncertainty.md
Last active May 16, 2017 12:31
Uncertainty in global climate databases: comparing Worldclim with Iberian climate atlas

Precipitation: Worldclim vs Iberian Climatic Atlas

Francisco Rodriguez-Sanchez 2017-05-16

library(knitr)
opts_chunk$set(cache = TRUE, message = FALSE)
library(raster)
@Pakillo
Pakillo / fig_label.R
Created April 10, 2017 17:03
R function to draw figure labels in base plots
## from: https://logfc.wordpress.com/2017/03/15/adding-figure-labels-a-b-c-in-the-top-left-corner-of-the-plotting-region/
fig_label <- function(text, region="figure", pos="topleft", cex=NULL, ...) {
region <- match.arg(region, c("figure", "plot", "device"))
pos <- match.arg(pos, c("topleft", "top", "topright",
"left", "center", "right",
"bottomleft", "bottom", "bottomright"))
if(region %in% c("figure", "device")) {
@Pakillo
Pakillo / simulate.gamm.R
Created March 3, 2017 16:53 — forked from gavinsimpson/simulate.gamm.R
S3 method for simulate() for "gamm" objects from package mgcv
`simulate.gamm` <- function(object, nsim = 1, seed = NULL, newdata,
freq = FALSE, unconditional = FALSE, ...) {
if (!exists(".Random.seed", envir = .GlobalEnv, inherits = FALSE))
runif(1)
if (is.null(seed))
RNGstate <- get(".Random.seed", envir = .GlobalEnv)
else {
R.seed <- get(".Random.seed", envir = .GlobalEnv)
set.seed(seed)
RNGstate <- structure(seed, kind = as.list(RNGkind()))