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
# ----------------------------------------------------------------------------- | |
# Example to check some taxa names with Taxonstand & wikitaxa | |
# ----------------------------------------------------------------------------- | |
my_sp <- fread("Output/taxa_to_check_VS.csv") | |
my_sp | |
# taxa | |
# Thereianthus_spicatus | |
# Eriocnema_fulva | |
# Hebe_macrocarpa | |
# Aspalathus_cymbriformis |
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) | |
library(ggsci) # for cool palettes | |
# read data | |
my_data <- read.csv("data/chickengrowthdiet.csv") | |
str(my_data) | |
# Diet should not be numeric but factor (or categorical) | |
my_data$Diet <- factor(my_data$Diet) | |
# ------------------------------------- |
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
##################################################### | |
# CI-s for linear model with ggplot | |
##################################################### | |
library(ggplot2) | |
# ------------------------------------- | |
# Use simulated data from Mick Wu | |
# ------------------------------------- | |
set.seed(1) |
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
setwd("share/") | |
getwd() | |
my_data <- read.table("data/drunkwalks_data.txt", header = TRUE) | |
plot(my_data) | |
aggreg <- table(my_data$SEX, my_data$DOMINANT_SIDE) | |
rownames(aggreg) <- c("female", "male") | |
colnames(aggreg) <- c("left-handed", "right-handed") |
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
# Example of using foreach parallel loop | |
# This should work both on Linux and Windows without any modifications. | |
# for an interesting intro, check: | |
# http://bgc.yale.edu/sites/default/files/ParallelR.html | |
library(foreach) | |
library(doParallel) | |
# Prepare cluster |
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
require(rgeos) | |
require(sp) | |
require(plotKML) | |
# Generate a random grid-points for a (almost) global bounding box | |
b.box <- as(raster::extent(120, -120, -60, 60), "SpatialPolygons") | |
proj4string(b.box) <- "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" | |
set.seed(2017) | |
pts <- sp::spsample(b.box, n=100, type="regular") | |
plot(pts@coords) |
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
make_GeodesicBuffer <- function(XY.dg, dg.step=5, dst.m, crs){ | |
####################################################################################################### | |
## Function to make a circle-buffer around given points (long-lat coordinates) | |
## Is different from rgeos::gBuffer() by the fact that it allows the user to create | |
## a geodesic buffer with a width expressed in metric units. | |
## Otherwise the user needs to project and apply an Euclidian buffer with rgeos::gBuffer(), | |
## which will introduce distortions that vary greatly with latitude and the radius of the circle buffer. | |
## See also my question addressed here: | |
## https://gis.stackexchange.com/questions/250389/euclidean-and-geodesic-buffering-in-r | |
## |
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
# Read <table> HTML tag with {XML} library | |
# ==================================================== | |
# Load library | |
library(XML) | |
# ======================= | |
# Read the web page [accessed 08-Apr-2017] | |
# ======================= | |
link <- "http://www.theplantlist.org/1.1/statistics/" |
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
# Read <table> HTML tag with {rvest} using CSS selectors | |
# ==================================================== | |
# Load library | |
library(rvest) | |
# ======================= | |
# Read the web page [accessed 08-Apr-2017] | |
# ======================= | |
link <- "http://www.theplantlist.org/1.1/statistics/" |
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
# Read <div> HTML tag with {rvest} using CSS selector | |
# ==================================================== | |
# Load library | |
library(rvest) | |
# ----------------------- | |
# Read the web page | |
# ----------------------- | |
link <- "http://www.adirondacklakessurvey.org/alscrpt.inc.php?alscpond=020225B&pname=ALLEGANY%20BROOK%20POND" |
NewerOlder