For your homework, we will use a sample plant diversity dataset to assess diversity called:

ENVS286_plant_abundance_SP17.csv

This dataset is measuring plant abundance for twelve grassland plots in Kansas. There are three habitat types (A, B, and C). You should have all the tools at your disposal from this lab (and previous labs) to answer the questions.

library(vegan)
## Loading required package: permute
## Loading required package: lattice
## This is vegan 2.4-3

Q1: Why can’t you just feed the plant abundance data set into the vegan package functions directly?

One reason we can’t just plug the data in is because there are a lot of missing data. The habitat column is also unnecessary for running the vegan because there is no numeric value.

Q2: Present the entire code that you would use to create a data frame with the three diversity indices for the plant abundance data.

Important Note: Once you get the final dataframe for your diversity indices above, you must as a column to create an (A, B, C) factor to run an ANOVA. To do this…

yourPlantDataframeName$HabitatFactor <- c(A,A,A,A,B,B,B,B,C,C,C,C)

#file.choose() use this function to find the path to the file we're inputing
plant<-read.csv("/Users/jonathan/Downloads/ENVS286_plant_abundance_SP17.csv")
plant[is.na(plant)]<-0
rownames(plant)<-plant$Habitat
plant$Habitat<-NULL
spPlant<-specnumber(plant)
HPlant<-diversity(plant,index="shannon")
DPlant<-diversity(plant,index = "invsimpson")
diversityResult<-data.frame(spPlant, HPlant, DPlant)
diversityResult$Habitat<-rownames(diversityResult)
diversityResult$Habitat
##  [1] "A1" "A2" "A3" "A4" "B1" "B2" "B3" "B4" "C1" "C2" "C3" "C4"

Q3: Choose one of the diversity indices for the plant abundance dataset. Run an ANOVA to analyze the results (check your assumptions). Supply the following:

diversityResult$HabitatFactor<-c("A","A","A","A","B","B","B","B","C","C","C","C")
diversityResult
##    spPlant   HPlant    DPlant Habitat HabitatFactor
## A1      16 2.441346  9.752381      A1             A
## A2      22 2.808373 13.363636      A2             A
## A3      21 2.828479 13.887052      A3             A
## A4       6 1.569423  4.328622      A4             A
## B1      10 1.922249  5.517241      B1             B
## B2      13 2.417064 10.083532      B2             B
## B3      29 3.043315 16.941176      B3             B
## B4      19 2.669353 12.236234      B4             B
## C1      16 2.513324 10.395939      C1             C
## C2      19 2.732360 13.481409      C2             C
## C3      31 3.199518 20.176471      C3             C
## C4      25 3.020502 17.917910      C4             C

A) Plot of your data

boxplot(diversityResult$spPlant~diversityResult$HabitatFactor)
Figure 1: Box plot of the data diversity results based on different habitat factors

Figure 1: Box plot of the data diversity results based on different habitat factors

B) evidence of residual normality and homoscedasticity

hist(diversityResult$spPlant)
Figure 2: Histogram to test for normality and a Q-Q plot to test for normality in residules

Figure 2: Histogram to test for normality and a Q-Q plot to test for normality in residules

qqnorm(diversityResult$spPlant)
qqline(diversityResult$spPlant)
Figure 2: Histogram to test for normality and a Q-Q plot to test for normality in residules

Figure 2: Histogram to test for normality and a Q-Q plot to test for normality in residules

C) ANOVA output

diversityResult$spPlant <- as.numeric(diversityResult$spPlant)
spPlant.aov<-aov(spPlant~HabitatFactor, data=diversityResult)
summary(spPlant.aov)
##               Df Sum Sq Mean Sq F value Pr(>F)
## HabitatFactor  2   92.7   46.33   0.827  0.468
## Residuals      9  504.3   56.03
plot(spPlant.aov)

## hat values (leverages) are all = 0.25
##  and there are no factor predictors; no plot no. 5

D) Tukey HSD results (if applicable)

Don’t need to run.

E) Reported Results Paragraph

There is no significant difference in the diversity of species listed in the dataset. Through using ANOVA we received a p-value of 0.468 signifying that we can’t reject the null hypothesis. Based on the p-value we can assume that there is a likelihood that there isn’t a difference between the habitats. The data was not transformed, and a Tukey test could not be run.

F) graph created with the plotting gizmo. Be sure to include an informative figure captions for the graphs.

GIZMO GIVEN BELOW. Remember: You need to adjust the parameters.
Figure 3: Graph of different plant species in 3 different habitats.

Figure 3: Graph of different plant species in 3 different habitats.

Please turn–in your homework via Sakai by saving and submitting an R Markdown PDF or HTML file from R Pubs!