install.packages('vegan') library(vegan) x <- c(2, 6, 158, 87, 2, 7, 1, 20, 19, 93, 2, 211, 240) #podenky - jepice lokality HLU2 Shannon1 <- diversity(x, index = "shannon", MARGIN = 1, base = exp(1)) #shannon index diverzity s prirodzenym logaritmom; mozeme pouzit aj index = "simpson" Shannon2 <- diversity(x, index = "shannon", MARGIN = 1, base = 2) #shannon index diverzity s logaritmom pri zaklade 2 Shannon1 [1] 1.791299 Shannon2 [1] 2.584299 # soubor "ptaci" jsou hnizdici ptaci z lokality Samorin - spolecenstva 1996 az 2001 ptaci <- read.csv("c:/DANKA HLAVNY ADRESAR/Vyuka/Bi5980 Biodiverzita/Biodiverzita vyuka 2016/03_2016_DataPtaci.csv",sep=";",dec=",", header=T) ptaci head(ptaci) tail(ptaci) attach(ptaci) X2001 Shannon1 <- diversity(X2001, index = "shannon", MARGIN = 1, base = exp(1)) Shannon1 [1] 2.621192 S <- specnumber(X2001) J <- Shannon1/log(S) J # Nosaciky - 7 lokalit, 84 druhov, tj. vsetky druhy; # Všetky druhy, 7 lokalit sledovanych v 2012-2014, od aprila do oktobra Nosaciky <- read.csv("c:/DANKA HLAVNY ADRESAR/Vyuka/Bi5980 Biodiverzita/Biodiverzita vyuka 2016/03_2016_Nosaciky.csv",sep=";",dec=",", header=F) Nosaciky Shannon <- diversity(Nosaciky, index = "shannon", MARGIN = 1, base = exp(1)) Shannon Simpson <- diversity(Nosaciky, index = "simpson") Simpson S <- specnumber(Nosaciky) S J <- Shannon/log(S) J N <- rowSums(Nosaciky) N # rarefaction - znovu bude tabulka otocena, tj. v radcich lokality, v sloupcich druhy # Function rarecurve draws a rarefaction curve for each row of the input data S <- specnumber(Nosaciky) (raremax <- min(rowSums(Nosaciky))) Srare <- rarefy(Nosaciky, raremax) plot(S, Srare, xlim = c(25, 45), pch=16, ylim = c(24,30), xlab = "Observed No. of Species", ylab = "Rarefied No. of Species") text(S, Srare, labels=rownames(Nosaciky), pos=3) abline(0, 1) rarecurve(Nosaciky) # nebo - kdyz nechceme mit nazvy spolecenstev v ramecku # rarecurve(Nosaciky, label = FALSE) # text(N, S, labels=rownames(Nosaciky), pos=4)