## Using {biscale} to plot bivariate raster maps
library(ggplot2)
library(biscale)
library(cowplot)
library(raster)
#> Loading required package: sp
This file contains 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
# Install R latest version: https://cloud.r-project.org/ | |
# For installing R on Linux, check out https://docs.rstudio.com/resources/install-r/ | |
# Instructions: https://moderndive.netlify.app/1-getting-started.html | |
# Install RStudio latest version: https://www.rstudio.com/products/rstudio/download/#download | |
# Open RStudio and install some R packages using the code below: | |
install.packages(c( | |
"tidyverse", |
This file contains 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
# Install R latest version: https://cloud.r-project.org/ | |
# Install RStudio latest version: https://www.rstudio.com/products/rstudio/download/#download | |
# Install R packages below: | |
install.packages(c( | |
"rmarkdown", | |
"knitr", | |
"dplyr", |
This file contains 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
# Install R latest version: https://cloud.r-project.org/ | |
# Install RStudio latest version: https://www.rstudio.com/products/rstudio/download/#download | |
# Install R packages below: | |
install.packages("remotes") | |
install.packages("workflowr") | |
remotes::install_github("benmarwick/rrtools") |
This file contains 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
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)) { |
This file contains 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) | |
t <- 1:100 # create time sequence | |
# warming trend, constant variance | |
clima <- data.frame(t = t, | |
temp = rnorm(100, 15 + 0.03*t, sd = 1)) | |
# warming trend + increasing variance | |
clima <- data.frame(t = t, |
This file contains 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
--- | |
title: "Having separate reference lists in an Rmarkdown document" | |
author: "F. Rodriguez-Sanchez" | |
output: | |
github_document: | |
pandoc_args: --lua-filter=multiple-bibliographies.lua | |
bibliography_main: main.bib | |
bibliography_suppl: suppl.bib | |
--- |
This file contains 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
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 |
As far as I know Rstudio does not count words or characters at the moment, which would be useful particularly when writing Rmarkdown.
This is a quick shortcut using word_count
and character_count
functions from qdap
package. See below for two wrapper functions that simplify their use.
library("qdap")
Just select and copy the text to the clipboard and then run in the console:
This file contains 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
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)) |