library(vegan)
library(vegetarian)
library(readxl)
library(writexl)
data<- read_excel(“F:/整理数据/三江源数据/汪悦监测表整理/agbzong/banma0β.xlsx”)
#每块样地有六个样本
data1 <- data[(1+60):(6+60),]
data2 <- data1[,-(1:3)]
data3 <- data2[,-(7:8)]
data3=as.data.frame(lapply(data3,as.numeric))#将数据框变为数据格式
data4 <- dplyr::filter(data3,禾本科!=“NA”)
a <- d(data4,lev = “alpha”,q=0) ## 平均alpha 物种丰富度
a1 <- as.data.frame(a)
a1$u <- 0
for (i in 1:186){
data1<- data[(1+6i):(6+6i),]
data2 <- data1[,-(1:3)]
data3 <- data2[,-(7:8)]
data3=as.data.frame(lapply(data3,as.numeric))
data4 <- dplyr::filter(data3,禾本科!=“NA”)
a <- d(data4,lev = “alpha”,q=0) ## 平均alpha 物种丰富度
a3 <- as.data.frame(a)
a3$u <- i
a1 = rbind(a1,a3)
}
b <- data[,1]
b1 <- unique(b)
b1$u <- 0:186
b2 <- merge(a1,b1,by.x = “u”, by.y = “u”)
/
data<- read_excel(“F:/整理数据/三江源数据/汪悦监测表整理/agbzong/banma0β.xlsx”)
data1 <- data[(1+60):(6+60),]
data2 <- data1[,-(1:3)]
data3 <- data2[,-(7:8)]
data3=as.data.frame(lapply(data3,as.numeric))
data4 <- dplyr::filter(data3,禾本科!=“NA”)
α_Shannon <- d(data4,lev = “alpha”,q=1) ## 平均alpha Shannon多样性
a1 <- as.data.frame(α_Shannon)
a1$u <- 0
for (i in 1:186){
data1<- data[(1+6i):(6+6i),]
data2 <- data1[,-(1:3)]
data3 <- data2[,-(7:8)]
data3=as.data.frame(lapply(data3,as.numeric))
data4 <- dplyr::filter(data3,禾本科!=“NA”)
α_Shannon <- d(data4,lev = “alpha”,q=1) ## 平均alpha Shannon多样性
a3 <- as.data.frame(α_Shannon)
a3$u <- i
a1 = rbind(a1,a3)
}
b3 <- merge(a1,b2,by.x = “u”, by.y = “u”)
############################