Project

General

Profile

Feature #6381 ยป Metric_Community_Stability.R

Sydney Jones, 01/15/2014 10:52 AM

 
1
#####################
2
##Community stability
3
#data format: long
4
#summing cover values by treatment then by species
5
require(plyr)
6

    
7
cs.sum <- ddply(data_raw.long, .(treatment, species). summarise,
8
					sum=sum(cover))
9
					
10
#calculating the mean sum and sd for each treatment
11
cs.sum.mean <- ddply(cs.sum, .(treatment), summarise,
12
						sumMean=mean(sum))
13
cs.sum.sd <- ddply(cs.sum, .(treatment), summarise,
14
						sumSd=sd(sum))
15
cs.m.sd <- join(cs.sum.mean, cs.sum.sd, type="full")
16

    
17
#calculating final comm. stability value per treatment
18
cs_final <- ddply(cs.m.sd, .(treatment), summarise,
19
					cs=mean/sd)
20
					
21
#ANOVA on cs values
22
require(car)
23

    
24
lm.cs.sum <- lm(sum ~ treatment, data=cs.sum)
25
Anova(lm.cs.sum, type=3)
26
summary(lm.cs.sum)
27

    
28
#KW ANOVA
29
fit.cs.kw <- kruskal.test(sum ~ treatment, data=sc.sum)
    (1-1/1)