0

This is my first question here so please excuse any mistakes I (may or may not) make.

The premise:

I got a vegetational dataset containing paired data on different plots for old and new observations. I used the 'openxlsx'-package to load my data, and 'vegan'-package to execute an NMDS as follows:

mydata <- read.xlsx(mydata)
mydataMDS <- metaMDS(mydata, k=2, trymax=500)

The result is then used for a model via the "envfit()"-function, including environmental variables:

myenvdata <- read.xlsx(myenvdata)
mydataMDS_fit <- envfit(mydataMDS, myenvdata, perm=10000, na.rm=TRUE)
plot(mydataMDS, display="sites")
plot(mydataMDS_fit, p.max=0.01, axis=TRUE)

Now I have a plot with my statistical "mydataMDS"-analyses, including vectors produced by the "mydataMDS_fit" R calculated.

The problem:

I want to colour and connect certain points within this plot. As "mydata" consists of observations within the same plot at different times, I intend to colour all points of old observations in one colour, and all the new ones in a different one. I've read about adding columns in order to group old and new observations, but as I'm working with a model there are no columns. How can I edit my datasets ("mydata", "mydataMDS", "myenvdata", "mydataMDS_fit") in order to show old and new plots in 2 different colours (one colour for old, one colour for new), and connect the paired observations with lines? Or: Is there a possibility to directly re-colour the points within my graphical output via checking for old/new observations?

(Sorry, I feel like my explanation is quite complicated, but I still hope someone may be able to help)

  • it would be best if you could provide a sample of the data which can be run on your code. – missuse Sep 13 '17 at 12:08
  • All you need is a variable that contains this information for your observations. The length of this variables must match with the number of observations, and each item of the variable also must match the observations (rows). However, you don't need to modify your files for this purpose. You can use this variable to define the colours of your points (use `col = myvar` in your `plot` or `points`). You may also check **vegan** functions `ordisegments`, `ordiarrows` etc which may be directly able to connect your points with lines with the help of this new variable. – Jari Oksanen Sep 13 '17 at 12:44
  • My data contains vegetational data following the Braun-Blanquet method for vegetation reliefs. It's a list containing index-data for every plant species found within every layer, for each plot. The environmental data contains indicator values following Ellenberg, species diversity and a few others. Both are dataframes with numerical data – KevinSchmidt Sep 14 '17 at 09:42
  • @JariOksanen, thank you for your input, I will try adding the variable and read about the **vegan** functions! Thanks again! – KevinSchmidt Sep 14 '17 at 09:45
  • I just found an old thread of 2013 which has a similar problem as I do, and - who would have thought - @JariOksanen answered it, too! I will link it here for convenience: [Here](https://stackoverflow.com/questions/20638505/r-create-double-labeled-mds-plot) – KevinSchmidt Sep 14 '17 at 11:03

0 Answers0