I am looking at how camera angle affects species % cover when using photoquadrats, and so have a dataframe where the first column is the sample, the second is angle (a factor) and the rest of the columns are different species abundances (numeric). It looks something like this:
df <- data.frame(ID = c(1, 2, 3, 4, 5,6,7,8,9,10,11,12),
angle = c('0','0','0','10','10','10','20','20','20','30','30','30'),
spec1 = c(0.3,0.2,0.5,0.5,0.8,0.6,0.1,0.5,0.1,0.2,0.5,0.3),
spec2 = c(0.2,0.4,0.3,0.5,0.1,0.3,0.3,0,0.7,0.8,0.2,0.6),
spec3 = c(0.5,0.3,0.2,0,0.1,0.1,0.6,0.5,0.2,0,0.3,0.1))
I want to eventually run a PERMANOVA on this using adonis (I have never used this function before so this is all new to me). I am not sure how to make my dataframe purely abundance data in order to run dist and get the dissimilarity matrix I need without getting rid of the factors which are what I want to tell the difference between in the first place.
I hope that makes sense - can anyone help?
Just make a new table, where the first two columns have been removed - this is your community data matrix. Then when you call adonis
you specify any predictors that you want from the specified data
. Just make sure that your community data matrix and your data
have the same number of rows.
library(vegan)
community <- df[,3:5]
adonis2(community ~ angle, data=df)