[R] PROBLEM: correspondence analysis with vegan

Jim Lemon drjimlemon at gmail.com
Thu Oct 27 00:32:43 CEST 2016

Hi Julia,
The error you got is usually due to data that should be numeric (1, 2,
3, ...) actually being a factor data type. This often happens when R
reads in a CSV file with the default option of converting character
variables (A, B, C,...) to factors. So your first column after input
may be a factor. Say your data frame (what you get after reading in
the CSV file) is named "mydf". Try this:


If that is TRUE, you have identified the problem with the error
message.I don't have the vegan package installed here at work, but if
there is an argument that specifies the labels for the arrows (this
may be "display="), you may be able to pass the first column of your
data frame to that argument and pass:

mydf[,-1] as the "data" argument. This is very much a guess, but might
help you to understand what is happening in the process. Also look at
the stringsAsFactors= argument in the read.csv function.


On Wed, Oct 26, 2016 at 11:20 PM, Julia Lienert via R-help
<r-help at r-project.org> wrote:
> 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.
> Greetings,
> Julia
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> 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