- H. Wickham: Official ggplot2 documentation
- H. Wickham: ggplot2 book
- W. Chang: R graphics cookbook and Cookbook for R
- Z. Ross: Beautiful plotting in R: A ggplot2 cheatsheet
- D. Koffman: Introduction to ggplot2
- R. Saccilotto: Tutorial: ggplot2
- R. Hartman: How to format plots for publication using ggplot2
- G. Williams: Visualising data with ggplot2
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
# Test of Significance, takes the same arguments as t.test() . | |
signif.test <- function(x, ...) { | |
p <- t.test(x, ...)$p.value | |
# List of p excuses retrieved from http://mchankins.wordpress.com/2013/04/21/still-not-significant-2/ | |
p_excuses <- c( | |
"(barely) not statistically significant <p>", | |
"a barely detectable statistically significant difference <p>", | |
"a borderline significant trend <p>", | |
"a certain trend toward significance <p>", |
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: "Reproducible R coding" | |
author: "Martin Jung" | |
date: "12.02.2015" | |
output: | |
ioslides_presentation: | |
highlight: zenburn | |
highlighter: highlight.js | |
hitheme: zenburn | |
slidy_presentation: |
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
# By Martin Jung (2015) | |
# http://conservationecology.wordpress.com/ | |
# Takes a IUCN species id code as input, which | |
# can ether be queried from the api (http://api.iucnredlist.org/) | |
# or directly from the full database downloadable here: | |
# http://api.iucnredlist.org/index/all.csv | |
isForestSpecialist <- function (inputID) | |
{ | |
print(paste("Now processing ID",inputID)) |
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
[1] "Key farm variables: area, livestock (LSU), labour force and standard output (SO) by agricultural size of farm (UAA), legal status of holding and NUTS 2 regions" | |
[2] "Key variables: area, livestock (LSU), labour force and standard output (SO) by economic size of farm (SO in Euro), legal status of holding and NUTS 2 regions" | |
[3] "Key variables: area, livestock (LSU), labour force and standard output (SO) by type of farming (2-digit) and NUTS 2 regions" | |
[4] "Land use: number of farms and areas of different crops by agricultural size of farm (UAA) and NUTS 2 regions" | |
[5] "Land use: number of farms and areas of different crops by economic size of farm (SO in Euro) and NUTS 2 regions" | |
[6] "Permanent crops: number of farms and areas by size of permanent crop area and NUTS 2 regions" |
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
# Include BAAD data | |
#http://www.esajournals.org/doi/abs/10.1890/14-1889.1 | |
library(dplyr) | |
library(ggplot2) | |
fd <- tempfile() | |
download.file("http://www.esapubs.org/archive/ecol/E096/128/baad_data.zip",destfile = fd) | |
b <- unzip(fd) | |
data <- read.csv("baad_data/baad_data.csv",header=T) # the data | |
meta <- read.csv("baad_data/baad_dictionary.csv",header=T) # the column explanations | |
# Filter those out without an age |
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
import os | |
import sys | |
import requests | |
basefname = 'Hansen_GFC2013_lossyear_%d%s_%03d%s.tif' | |
baseurl = 'http://commondatastorage.googleapis.com/earthenginepartners-hansen/GFC2013/%s' | |
def download(url, output): |
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
# MJ 14/12/2015 | |
#### Load or install packages #### | |
if(!require(devtools))install.packages("devtools");library(devtools) | |
if(!require(rAltmetric))install.packages("rAltmetric");library(rAltmetric) | |
if(!require(plyr))install.packages("plyr");library(plyr) | |
if(!require(ggplot2))install.packages("ggplot2");library(ggplot2) | |
# This script expects a csv file with title / year / journal / doi | |
refs <- read.csv("ScharlemannlabPublications.csv",header = T,stringsAsFactors = F) |
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
# Arguments: | |
# - model = a clmm model | |
# - newdata = a dataframe of new data to apply the model to | |
# Returns a dataframe of predicted probabilities for each row and response level | |
fake.predict.clmm <- function(model, newdata) { | |
# Actual prediction function | |
pred <- function(eta, theta, cat = 1:(length(theta) + 1), inv.link = plogis) { | |
Theta <- c(-1000, theta, 1000) | |
sapply(cat, function(j) inv.link(Theta[j + 1] - eta) - inv.link(Theta[j] - eta)) | |
} |
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
stat_smooth_func <- function(mapping = NULL, data = NULL, | |
geom = "smooth", position = "identity", | |
..., | |
method = "auto", | |
formula = y ~ x, | |
se = TRUE, | |
n = 80, | |
span = 0.75, | |
fullrange = FALSE, | |
level = 0.95, |
OlderNewer