2

I'm trying to plot a pca biplot in ggplot with ellipsoids for groups, and I found an example in this thread here.

However, I can't reproduce the result. I ran both versions of Didzis Elfer's solution, but the df_ell dataframe remains empty. When I run the last command:

ggplot(data = NMDS, aes(MDS1, MDS2)) + geom_point(aes(color = group)) +
geom_path(data=df_ell, aes(x=NMDS1, y=NMDS2,colour=group), size=1, linetype=2)

I get the following error: Error in FUN(X[[i]], ...) : object 'NMDS1' not found

So it seems the function doesn't work. Does it have to do with the most recent version of the vegan package?

All help is appreciated.

Sam Vanbergen
  • 145
  • 3
  • 11

1 Answers1

1

Very late, but i was running into the same problem.

Check if levels(NMDS$group) returns NULL. Converting your grouping variable from character to factor did fix the problem for me. In Didzis Elfer's solution a simple

NMDS$group <- as.factor(NMDS$group)

was enough to get the function running.

nouse
  • 3,315
  • 2
  • 29
  • 56