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
# The palette with grey: | |
cbPalette <- c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7") | |
# The palette with black: | |
cbbPalette <- c("#000000", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7") | |
# To use for fills, add | |
scale_fill_manual(values=cbPalette) | |
# To use for line and point colors, add |
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
## generate data | |
x = factor(sample(letters[1:5],100, replace=TRUE)) | |
print(levels(x)) ## This will show the levels of x are "Levels: a b c d e" | |
## To reorder the levels: | |
## note, if x is not a factor use levels(factor(x)) | |
x = factor(x,levels(x)[c(4,5,1:3)]) | |
print(levels(x)) ## Now "Levels: d e a b c" |
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
ggplot() + | |
coord_cartesian() + | |
scale_x_continuous() + | |
scale_y_continuous() + | |
scale_color_hue() + | |
facet_wrap(~cut) + | |
layer( | |
data=diamonds, | |
mapping=aes(x=carat, y=price, color=color), | |
stat="identity", |
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]: | |
# [Date]: [Loc]: | |
# Pedro Jordano. | |
# ---------------------------------------------------------------------------- | |
## First version __DATE__. Revised __DATE__ | |
# ---------------------------------------------------------------------------- |
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
###################################################################### | |
# Function bdiag to build the canonical form of a matrix | |
#--------------------------------------------------------------------- | |
# Pedro Jordano. 18 Dic 2007. | |
#--------------------------------------------------------------------- | |
bdiag <- function(x){ | |
if(!is.list(x)) stop("x not a list") | |
n <- length(x) | |
if(n==0) return(NULL) | |
x <- lapply(x, function(y) if(length(y)) as.matrix(y) else |
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
#----------------------------------------------------------------------------- | |
# Testing the difference between two CV's | |
# From Example 8.12 in Zar, p. 144-145 | |
#----------------------------------------------------------------------------- | |
w<-c(72.5,71.5,60.8,63.2,71.4,73.1,77.9,75.7,72.0,69.0) | |
h<-c(183.0,172.3,180.1,190.2,191.4,169.6,166.4,177.6,184.7,187.5,179.8) | |
#----------------------------------------------------------------------------- | |
# Testing the difference between two CV's | |
library(MBESS) | |
n1<-length(w); n2<-length(h) |
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
******************************************************************* | |
*** Solutions to a question I posted on the R-news mailing list *** | |
*** about simple table manipulation *** | |
*** Campbell Webb post in R-help *** | |
******************************************************************* | |
THE QUESTION: | |
Hi all, |
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
#-------------------------------------------------------------------- | |
# Function for Levy walk from source fixed point | |
# Pedro Jordano. 7 Apr 2009. | |
# Specify: | |
# R> levy(n,mu,l0) | |
# Where: n, is the number of events (default, n= 500) | |
# mu, is the Levy exponent (default, mu= 2.0) | |
# l0, is step size (default, l0= 1) | |
#-------------------------------------------------------------------- | |
levy<-function (n= 500, mu= 2.0, l0= 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
############################################################################## | |
### LÉVY WALK CODE | |
#----------------------------------------------------------------------------- | |
library(adehabitat) | |
set.seed(411) | |
w <- simm.levy(1:500, mu = 1.5, burst = "mu = 1.5") | |
u <- simm.levy(1:500, mu = 2, burst = "mu = 2") | |
v <- simm.levy(1:500, mu = 2.5, burst = "mu = 2.5") | |
x <- simm.levy(1:500, mu = 3, burst = "mu = 3") | |
par(mfrow=c(2,2)) |
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
################################################################# | |
# Network analyses. | |
# Pedro. 7 Dec 2007 | |
################################################################# | |
# NOTE: These matrices have rows are animals, columns are plants. | |
# NOTE: JORDI's datasets for NESTEDNESS have Rows are plants, | |
# columns are animals. | |
library(bipartite) | |
library(networksis) | |
library(igraph) |