0

I am performing a redundancy analysis in RStudio. My data includes several environmental variables as the community data matrix, and a GROUP column, which is the constraining matrix. For example:

CONDUCTIVITY    pH    GROUP
453            7.5    A
462            7.7    A
500            8.1    B
525            8.0    B
308            8.4    C
306            8.5    C

I am doing a redundancy analysis to compare the environmental variables between groups (which represent locations), such as, is the conductivity in group A significantly different than the conductivity in group B. My R script is as follows:

df <- read.csv("All_data_long_format.csv")

library(vegan)

rda <- rda(df[,2:9] ~ df$GROUP) # columns 2 to 9 are the environmental variables

I get the error:

Error in terms.formula(formula,"Condition",data=data): 'data' argument is of the wrong type.

I'm not sure what this means, but my guess is 'df' is the wrong type, but I'm not sure why or how to solve it.

Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294
user8502082
  • 1
  • 1
  • 1
  • if you run `str(df)` on your data, it will tell you whether or not it is a data frame. If it is, unless rda was designed to work on a specific class of object in r, the function should probably work. In looking at the data here, you have 3 columns, but your code evaluates columns 2 through 9 . against Group, which happens to be column three in this example. If it is also located within the 2:9 range above, then rda is likely not sure how to discriminate against a column included in the analysis – sconfluentus Aug 22 '17 at 19:03
  • Sorry, I was unclear. I have more environmental variables than conductivity and pH, so columns 2 to 9 are these, and column 10 is the group. I didn't show my full table. When i run str(df), the environmental variables show up as numbers. Is this incorrect? – user8502082 Sep 01 '17 at 22:35

0 Answers0