D. Guo
D. Guo

Reputation: 1

I cannot obtain scores for a metaMDS object in RStudio (package: vegan)

I'm using vegan 2.6.4 in RStudio, and have had an unusual error message pop up when I run the the following:

nmds11 = metaMDS(m_com11, distance = "bray")
data.scores11 = as.data.frame(scores(nmds11)$sites)
Error in UseMethod("scores") : 
  no applicable method for 'scores' applied to an object of class "c('metaMDS', 'monoMDS')

I can safely say this has never happened to me, and I was using the exact same code on a different dataset 5 minutes ago with no issues. I have also previously run this same script on at least a dozen other matrices with no errors.

I have tried calling scores.metaMDS as suggested when looking up the scores function (to help specify what type of object I'm trying to get scores from), but that function apparently does not exist. I've also tried running some old scripts that always worked in the past, with the same unfortunate results.

Any idea what I can do to address this?

Upvotes: 0

Views: 846

Answers (2)

NicoSchiff
NicoSchiff

Reputation: 1

I I tried vegan:::scores.metaMDS() without restarting RStudio and it works ! Thanks !!!

Upvotes: 0

Gavin Simpson
Gavin Simpson

Reputation: 174928

Try using vegan::scores(); it could be that some other package you have loaded also has a scores() generic that is overwriting vegan::scores(). You can also try the much more specific vegan:::scores.metaMDS() if the whole S3 system has gotten clobbered.

Beyond that, restart R (in RStudio, find the Restart R option in the menus) so you get a clean session and try running your code again.

Upvotes: 1

Related Questions