Entering edit mode

4.9 years ago

Ginsea Chen
▴
130

Dear all
I tried to use vegan of R to perform RDA analysis for 16s rDNA datasets, while my enrichment factor is not numeric, such as one group data from Young species, while another group from old species. So, **my question is how to transfer this non numeric enrichment factor to numeric(like PH values).** If you have some suggestions, please tell me. Thanks for your help.

Could you clarify your question ? In particular, are your enrichment factors numbers that happen to be encoded in a non-numeric R data type or are they represented by a categorical variable ?

In the first case, as.numeric(x) should do or if it's an R factor variable, you would need as.numeric(levels(x)[x]). If your enrichment factor is a categorical variable and you know some numerical values associated with each then you could substitute the values for the categories. Otherwise, you could do as is sometimes done in regression: create dummy variables, one less than the number of categorical variables and assign them 0 or 1 based on category membership.

Also, have you checked that rda() can not already deal with categorical variables ?