This file contains hidden or 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: "SIA biplots using ggplot2" | |
author: "Andrew L Jackson & Chris Harrod" | |
date: "`r Sys.Date()`" | |
output: html_notebook | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE, fig.width = 9, fig.height = 6) | |
``` |
This file contains hidden or 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
# examples of iteration estimates | |
# iteration 1, model 1 | |
it1.m1<-c(0.007439839, 0.229489378, 0.035664652, 0.015154735, 0.712251396) | |
# iteration 2, model 1 | |
it2.m1<-c(0.04197685, 0.22032073, 0.05718590, 0.03484489, 0.64567163) | |
# iteration 1, model 2 | |
it1.m2<-c(0.09325976, 0.29549676, 0.15327778, 0.08599277, 0.37197294) | |
# iteration 2, model 2 | |
it2.m2<- c(0.06429175, 0.02222554, 0.15422684, 0.65528134, 0.10397452) |
This file contains hidden or 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
# About: Code to calculate JDI and produce barplot as per | |
# https://scientistseessquirrel.wordpress.com/2017/08/03/my-journal-life-list/ | |
# Additional code from | |
# https://www.r-bloggers.com/yet-another-post-on-google-scholar-data-analysis/ | |
# Author: Andrew Jackson | |
# http://www.tcd.ie/Zoology/research/research/theoretical/andrewjackson.php | |
# Date: 04-Aug-2017 | |
This file contains hidden or 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
theta <- seq(0, 2*pi, length = 360) | |
Z <- data.frame(x = cos(theta), y = sin(theta)) | |
par(mfrow = c(2,2)) | |
# points in order | |
plot(y~x, data = Z, type = "l", main = "Made in order", asp = 1) |
This file contains hidden or 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(dplyr) | |
# use the iris dataset | |
dd <- iris | |
# The normal way to group or split is by directly referencing the var object | |
dd %>% group_by(Species) | |
dd %>% split(.$Species) |
This file contains hidden or 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(tidyverse) | |
# create a list of length 10 with a small dataframe in each entry | |
df <- lapply(1:10,function(x){data.frame(y = 1:5)}) | |
# convert to tbl | |
df_tbl<- bind_rows(df, .id = "id") | |
# pluck out the last entry for each "id" using slice() | |
last_entry <- df_tbl %>% group_by(id) %>% slice(n()) |
This file contains hidden or 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
# code based on https://en.wikipedia.org/wiki/Mahalanobis_distance | |
set.seed(1) | |
# define a point D | |
x <- matrix(rmnorm(1, c(2,2), matrix(c(1,0.1,0.1,1), 2, 2)), 1, 2) # vector of locations in 2 dimensional space | |
x <- t(x) # transpose | |
# Define a multivariate normal distribution for comparison | |
mu <- matrix(c(0, 0), 1, 2) # vector of bivariate means |
This file contains hidden or 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
strength = [82 86 79 83 84 85 86 87 74 82 ... | |
78 75 76 77 79 79 77 78 82 79]; | |
alloy = {'st','st','st','st','st','st','st','st',... | |
'al1','al1','al1','al1','al1','al1',... | |
'al2','al2','al2','al2','al2','al2'}; | |
% NB also works on two-way anovas using anova2() | |
[p, tbl, stats] = anova1(strength,alloy,'off') | |
% this line will compute pairwise comparisons, at the usual |
This file contains hidden or 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(plyr) | |
#require(siar) | |
t1 <- data.frame(SizeClass=c("Meiofauna","Smaller Macrofauna","Bigger Macrofauna"), | |
num=rpois(3,10), | |
md13C=rnorm(3,-10,10), | |
sd13C=rlnorm(3,1,1), | |
md15N=rnorm(3,5,5) , | |
sd15N=rlnorm(3,1,1)) | |
t1 |
This file contains hidden or 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(plyr) | |
require(siar) | |
t1 <- data.frame(SizeClass=c("Meiofauna","Smaller Macrofauna","Bigger Macrofauna"), | |
num=rpois(3,10), | |
md13C=rnorm(3,-10,10), | |
sd13C=rlnorm(3,1,1), | |
md15N=rnorm(3,5,5) , | |
sd15N=rlnorm(3,1,1)) | |
t1 |
NewerOlder