[R] PROBLEM: correspondence analysis with vegan

David L Carlson dcarlson at tamu.edu
Wed Oct 26 20:05:07 CEST 2016

The organization of your data is not clear from your description. You say you have species and samples and that the rows are the species, but the columns (which should be the samples) are "zonation + land use". I'm guessing that you mean the first column was zonation and land use and the remaining columns were samples? Your problem is not so much with R as with not knowing how to use the vegan package to do correspondence analysis. 

Fortunately, the vegan package comes with several documents describing how to use it called vignettes. You can see their names with the following command:

> vignette(package="vegan")

Then read the "intro-vegan" one:

> vignette("intro-vegan")

Also Jari Oksanen has a nice tutorial on his web page that you should read:


I suspect you are trying to do constrained ordination, but I may be wrong since you did not show us any of your code. If so, you should also read the manual page for the cca() function and look at the examples.
> ?cca
> example("cca") # Will run them for you

Look at the examples carefully and display the data sets so that you know how they are organized using the str() function to study the structure of the data and View() to display it.

David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352

-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Julia Lienert via R-help
Sent: Wednesday, October 26, 2016 7:21 AM
To: r-help at stat.math.ethz.ch
Subject: [R] PROBLEM: correspondence analysis with vegan

Hello All,

I’m Julia from Germany and I have a problem concerning the vegan package that I can’t solve on my own (after hours and hours spent searching for a solution). I was thrown into the topic of working with R by my professor and wasn’t really aware that this included working with higher statistics (since I studied pedagogy before and have not much basic statistical knowledge or knowledge of R).

I need to do a correspondence analysis on a dataset of vegetation samples and species as a comma-separated csv file. I have the species names as row names. The column names indicated zonation + land use and make up the first row of the matrix. I set the header = TRUE. 

If I tried doing a CA or DCA with this dataset the warning “Error in rowSums(X): ‘x’ must be numeric” appeared. According to several forums, I then removed the first column and the CA worked and i could also apply the envfit function and plot it. 

Now here comes my problem and question:

when I plotted the arrows { plot(ef, p.max = 0.1) }, I got arrows labeled with species in my ordination plot. But instead I would need the column that indicates the zonation/land use (the first column) which I had to remove in order for the CA/ DCA to work. Is there any way that I can incorporate the zonation/ land use column as environmental vector after I did the whole CA/ DCA? Or is there any way for me to do a CA/ DCA without having to remove the first column?

I might be missing something but I just started working with R and haven’t got the time to really work my way in from the basics. I will do that after this project is done but for now I just hope that you can help me.


R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list