Skip to content

Instantly share code, notes, and snippets.

🌳
Living the Bayesian dream

Francisco Rodriguez-Sanchez Pakillo

🌳
Living the Bayesian dream
View GitHub Profile
@Pakillo
Pakillo / diverge0.R
Created Dec 12, 2019 — forked from johnbaums/diverge0.R
Plot a rasterVis::levelplot with a colour ramp diverging around zero
View diverge0.R
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())) {
View Sentinel2-repaso.R
## Working with Sentinel-2 bands in R
# Crear proyecto de RStudio
## Cargar paquetes necesarios
library(raster)
View 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 Sep 3, 2018
Figure of Cenozoic (last 66 million years) and future global temperatures expected with climate change
View cc_paleotemp.R
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 Mar 21, 2018
another reproducible map with Rstats
View repromap.R
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
Uncertainty in global climate databases: comparing Worldclim with Iberian climate atlas
View Worldclim_Precipitation_Uncertainty.md

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 Apr 10, 2017
R function to draw figure labels in base plots
View fig_label.R
## 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 Mar 3, 2017 — forked from gavinsimpson/simulate.gamm.R
S3 method for simulate() for "gamm" objects from package mgcv
View simulate.gamm.R
`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()))
@Pakillo
Pakillo / ShinyPerspectivePlot.R
Created Dec 19, 2016 — forked from leeper/ShinyPerspectivePlot.R
Shiny App for 3D Interaction plots
View ShinyPerspectivePlot.R
library("shiny")
library("shinyjs")
ui <- shinyUI(pageWithSidebar(
titlePanel("", "3D Perspective Plot for Interaction Effects"),
sidebarPanel(
tabsetPanel(
tabPanel("Data",
You can’t perform that action at this time.