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
#!/bin/bash | |
# Usage: mkproj [projectname] | |
# projectname defaults to name of current directory | |
template="Version: 1.0\nRestoreWorkspace: Default\nSaveWorkspace: Default\nAlwaysSaveHistory: Default\n\nEnableCodeIndexing: Yes\nUseSpacesForTab: Yes\nNumSpacesForTab: 4\nEncoding: UTF-8\n\nRnwWeave: knitr\nLaTeX: pdfLaTeX" | |
wd=$(basename `pwd`) | |
if [ -z $1 ]; then |
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
## Empty list -- just use the empty environment for this. | |
nil <- function() { | |
emptyenv() | |
} | |
## Test if a list is the empty list: | |
is_empty <- function(lis) { | |
identical(lis, nil()) | |
} |
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
set.seed(1) | |
# Create fake data | |
x = runif(100, 0, 5) | |
y = .25 * x^3 - x^2 + rnorm(length(x)) | |
data = data.frame(x = x, y = y) | |
# Identify 500 points to include in the plots | |
x.sequence = seq(0, 5, length = 500) |
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
getmatch <<- function(x,str2match,...) { | |
unlist(regmatches(x,regexpr(str2match,x,...))) } |
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(lme4) | |
library(ggplot2) | |
#create some levels | |
levs <- as.factor(c("l1","l2","l3","l4","l5")) | |
#set the factor means | |
f_means <- c(6,16,2,10,13) | |
# set individual as a factor |
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
## file-scan.r | |
## Function to find a pattern in files with user-defined extension (.r by default) | |
## Returns file name and approximate row matches if positive. | |
## ------------------------------------------------------- | |
## Author: Laura Tremblay-Boyer ([email protected]) | |
## Written on: March 26, 2013 | |
## Time-stamp: <2013-03-26 16:19:28 Laura> | |
file.scan <- function(pattern, dir=getwd(), fpattern=NA, ftype=".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
######### These are my attempts to incorporate McCann's models into R to help me interpret these food web models ###################### | |
library(deSolve) | |
### Section 2.2.5 | |
# parameters and state variables for the R-M model | |
r <- 1.0 # per capita rate of increase in resource | |
K <- 2.0 | |
e <- 0.7 | |
Ro <- 0.5 |