-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstats.R
47 lines (35 loc) · 793 Bytes
/
stats.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
library(tidyverse)
library(agricolae)
flux<-read_csv("data/mesocosm_fluxes.csv")
head(flux)
colnames(flux)<-c("hour", "date", "core", "N", "ins")
flux<-filter(flux, N != "NA", hour > 59)
dif<- function(df) {
mod <- aov(df$N ~ df$ins)
tuk <- TukeyHSD(x=mod, 'df$ins', conf.level=.95)
pvalue <- tuk[[1]][,4]
pvalue
}
sas<- function(df) {
mod <- lm(df$N ~ df$ins)
tuk <- HSD.test(mod, 'df$ins')
letter <- tuk$groups
letter
}
ttest<- function(df) {
mod <- t.test(df$N ~ df$ins)
mod[[3]]
}
now<-flux%>%
group_by(hour)%>%
do(pvalue=dif(.))
then<-flux%>%
group_by(hour)%>%
do(pvalue=sas(.))
try<-flux%>%
group_by(hour)%>%
do(pvalue=ttest(.))
best<-filter(flux, hour == 144)
ggplot(best, aes(x=ins, y=N))+
geom_boxplot()
best_mod<-lm(N ~ ins, best)