Skip to content

Instantly share code, notes, and snippets.

View aurielfournier's full-sized avatar
💭
Crunching numbers about birds and how we value them

Auriel M.V. Fournier aurielfournier

💭
Crunching numbers about birds and how we value them
View GitHub Profile
dat <- data.frame(A=c(1,2,3,4,5,6), B=c("Dog","Cat","Bird"))
dat2 <- dat[dat$B!="Bird",]
uni <- unique(dat2$B)
dat2$B <- factor(dat2$B, levels=uni)
library(sjPlot)
library(sjmisc)
library(lme4)
# load sample data set.
data(efc)
efc$scale_c12hour <- scale(efc$c12hour)
efc$scale_e15reat <- scale(efc$e15relat)
m <- glmer(c175empl ~ scale_c12hour + scale_e15reat + (1|resttotn), data=efc, family=binomial(link = "logit"))
@aurielfournier
aurielfournier / distanim.R
Created February 2, 2017 17:55 — forked from dill/distanim.R
Animation of a simple distance sampling survey.
# animate a (very boring) distance sampling survey
# watch a gif at: http://converged.yt/distance-animation.gif
# written by David Lawrence Miller, with tweaks from Eric Rexstad
# released under the MIT license
library(animation)
# make sure that we get the same result every time...
set.seed(1234)
# Make Example Graph/Data
a <- data.frame(firstcolumn=seq(1:10), secondcolumn=seq(21:30), thirdcolumn=seq(41:50))
ggplot()+
geom_point(data=a, aes(x=firstcolumn, y=secondcolumn, fill=thirdcolumn))
# One method is to make the column a character instead of a number, than it treats it as discrete
a <- data.frame(firstcolumn = seq(1:10), secondcolumn=rep(c("somestuffhere","someotherstuff"), 5))
a$secondcolumn <- ordered(a$secondcolumn, levels=c("somestuffhere", "someotherstuff"), labels=c("somestuff \nhere", "someother \nstuff"))
do({spre <<- .; .}) %>%
cool_science_stuff <- data.frame(a=runif(20, 2, 5), b=runif(20, 5, 10), c=rep("long name \nof a thing", 20))
library(ggplot2)
ggplot(data=cool_science_stuff)+
geom_boxplot(aes(x=c, y=a))
###
cool_science_stuff <- data.frame(a=runif(20, 2, 5), b=runif(20, 5, 10), c=rep("long name \nof a thing", 20))
ggplot(data=cool_science_stuff)+
geom_boxplot(aes(x=c, y=a))
dat <- data.frame(a=c(01,2,3,4,2),b=c(4,3,6,5,4))
ggplot()+geom_point(data=dat, aes(x=a, y=b))+ylab(paste0("\u03B4", ^13, "C", "\u2030"))
# I need this to be the delta symbol a super script 13, a Captal C and the per mil symbol
(pp <- ggplot()+
geom_line(data=fit, aes(x=x, y=y, group=year))+
geom_ribbon(data=fit, alpha=0.6, aes(x=x, ymin=lower, ymax=upper, fill=year))+
scale_fill_manual(values=mypal)+
theme_krementz()+
scale_x_continuous(breaks=seq(225,300,5),limits=c(225,300),
labels=c("August 10","August 15","August 20", "August 25","August 30","September 4","September 9","September 14","September 19","September 24","September 29","October 4","October 9","October 14","October 19","October 24"))+
xlab("Date")+
ylab("Sora per Hectare"))