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
library(shiny) | |
library(ggplot2) | |
library(rgbif) | |
## Set up server output | |
shinyServer(function(input, output) { | |
# define function for server plot output | |
output$gbifplot <- reactivePlot(function() { | |
splist <- input$spec |
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 csv | |
open("test.csv","w").close() | |
dat = ['one potato','two potato'] | |
dat2 = ['3 potato','four'] | |
dat3 = ['8 potatos','9 potatoes'] | |
mydat = [dat,dat2,dat3] | |
with open("test.csv","a") as csvfile: | |
mywriter = csv.writer(csvfile, delimiter=",") | |
for x in mydat: |
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
theme.blank = function(size=12) { | |
theme( | |
#axis.line=element_blank(), | |
axis.text.x=element_text(size=size), | |
axis.text.y=element_text(size=size), | |
#axis.ticks.y=element_text(size=size), | |
# axis.ticks=element_blank(), | |
axis.ticks.length=unit(0.1, "lines"), | |
axis.ticks.margin=unit(0.5, "lines"), | |
axis.title.x=element_text(size=size*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
library(ggplot2) | |
# n is the number of iterations for the test | |
# j is the number of matrices to create | |
# m is the size of the square matrix to solve | |
loops <- function(n,j,m){ | |
for(i in 1:n){ | |
mylist <- list() | |
for(x in 1:j){mylist[[x]]<- matrix(rnorm(m^2),nrow=m,ncol=m)} | |
for(x in 1:j) {z <- solve(mylist[[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
#' Description: Code using deSolve for some simple ecological ODE models | |
#' There are 3 examples, one is a simple LV Pred-Prey example with plots | |
#' The next is a Macarthur-Wilson model with plots of both the species curve and the equlibrium points | |
#' The last plot is a quick crack at putting stochasticity into the model by adding oscillations in I with t. | |
#' LV code is modified from a blog post here: http://assemblingnetwork.wordpress.com/2013/01/31/two-species-predator-prey-systems-with-r/ | |
#' Other additions are my own | |
#' | |
#' Author: Edmund Hart | |
#' Date: 3/28/2013 | |
#' E-mail: [email protected] |
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 random as rn | |
from ipythonblocks import BlockGrid | |
def draw_srpk_tri(dim = 100, iterations = 1000, background_color = (255,255,255), triangle_color = (0,0,0) ,block_size = 3): | |
''' | |
Draws a Sierpinski triangle using the chaos game approach (http://en.wikipedia.org/wiki/Chaos_game) | |
Parameters: | |
dim -- integer, the dimensions of the square to draw the triangle in, default is 100 | |
iterations -- integer, the number of points to create the triangle with, the higher the value, the more resolution, default is 1000 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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(xtable) | |
insane <- data.frame(Name=c("Ampersand","Greater than","Less than","Underscore","Per cent","Dollar","Backslash","Hash", "Caret", "Tilde","Left brace","Right brace"), Character = I(c("&",">", "<", "_", "%", "$", "\\", "#", "^", "~","{","}"))) | |
colnames(insane)[2] <- paste(insane[,2],collapse="") | |
print( xtable(insane),type='html',sanitize.text.function = function(x){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(rWBclimate) | |
library(rgbif) | |
splist <- c("Junco hyemalis", "Aix sponsa") | |
out <- occurrencelist_many(splist, coordinatestatus = TRUE, maxresults = 20) | |
options(kmlpath = "/Users/edmundhart/kmltemp") | |
sp.map.df <- create_map_df(c("USA","MEX")) | |
sp.map <- ggplot(sp.map.df,aes(x=long,y=lat,group=group))+geom_polygon(fill="white",colour="black")+xlim(-130,-65)+ylim(12,50) | |
sp.map + geom_point(data=gbifdata(out),aes(y=decimalLatitude,x=decimalLongitude,group=taxonName,colour=taxonName)) |