#ORDINATION FUNCTION #Reads your data file, #performs ordination (Non-Metric Multidimensional Scale), #and plots results #If you haven't already, go to "Install Packages" in the "Tools" menu #Then, type "vegan" in the box and click on "Install" (wait for it to finish) #You only need to install the package once, but you need to run step 1 every time you start the program ordination <- function(groupnum) { #read your data file commdata <- read.csv(paste("https://people.ucsc.edu/~mclapham/eart101/papers/group_",groupnum,"_data.csv", sep=""), row.names=1) #perform the ordination analysis mdsres <- vegan::metaMDS(t(commdata), autotransform=F) #plot the ordination results #sites are plotted as solid circles with labels #species are plotted as red text plot(mdsres, type="n") mdsscores <- vegan::scores(mdsres) spscores <- vegan::scores(mdsres, display="species") points(mdsscores, pch=16) text(mdsscores[,1], mdsscores[,2]-0.04, sample_num <- gsub("\\..*","", colnames(commdata))) text(spscores[,1], spscores[,2], rownames(commdata), col="red", cex=0.75) #End of STEP 5 #To save the plot, click the "export" option above the plot window and then select "save as image." #Set the file name and use the "directory" button in the save window to choose the folder where it will be saved. }