## HEADER #### # ## Project: # NMDS tutorial following Jeff's approach # ## Last editor: Ana Natalio # ## Last edited: 2020.04.01 # ## CONTENTS #### ## 00 Setup ## 01 What's NMDS? ## 02 How does it work? ## 03 Let's do it in R ## 04 References # ## 00 Setup #### # setwd("M:/Stats_Demos/NMDS") # add here your personal working directory # # install.packages("vegan") # library(vegan) # ## 01 What's NMDS? #### ## 02 How does it work? #### ## 03 Let's do it in R #### # set.seed(2) # community_matrix = matrix( sample(1:100, 300, replace = T), nrow = 10, dimnames = list(paste("community", 1:10, sep = ""), paste("sp", 1:30, sep = ""))) # example_NMDS = metaMDS(community_matrix, k = 2) # stressplot(example_NMDS) # plot(example_NMDS) # ordiplot(example_NMDS, type = "n") orditorp(example_NMDS, display = "species", col = "red", air = 0.01) orditorp(example_NMDS, display = "sites", cex = 1.25, air = 0.01) # treat = c(rep("Treatment1", 5), rep("Treatment2", 5)) ordiplot(example_NMDS,type = "n") ordihull(example_NMDS, groups = treat, draw = "polygon", col = "grey90", label = F) orditorp(example_NMDS, display = "species", col = "red", air = 0.01) orditorp(example_NMDS, display = "sites", col = c(rep("green", 5), rep("blue", 5)), air = 0.01, cex = 1.25) # # Non-metric multidimensional scaling (axes NMDS1 vs. NMDS2) using the species (Sp-n) and # sites (Community-n) distances between species assemblages under two different treatments # accross ten sites located on the West Coast of Scotland (Stress = 0.17). # ## 04 References #### # # https://jonlefcheck.net/2012/10/24/nmds-tutorial-in-r/ # https://rstudio-pubs-static.s3.amazonaws.com/246172_1930ddfb5f064b2bab54b11016ab407e.html