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
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) |
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(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")) |
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
# 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) |
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
# 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 |
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
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")) |
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
do({spre <<- .; .}) %>% |
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
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)) | |
### | |
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
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)) |
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
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 |
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
(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")) |