Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue with adonis2() using formula and data notation #521

Open
luismmontilla opened this issue Jul 22, 2022 · 1 comment
Open

issue with adonis2() using formula and data notation #521

luismmontilla opened this issue Jul 22, 2022 · 1 comment

Comments

@luismmontilla
Copy link

I've noticed that adonis2() returns the following error when using the notation adonis2(formula, data), e.g.:

library(palmerpenguins)
library(vegan)

penguins <- penguins[!is.na(penguins$bill_length_mm),]

# Works fine
adonis(bill_length_mm~species*island,
       data = penguins,
       method = "euclidean")

#Outputs the error
adonis2(bill_length_mm~species*island,
       data = penguins,
       method = "euclidean")

#Error in eval(YVAR, environment(formula), globalenv()) : 
# object 'bill_length_mm' not found

#However, if instead of using formula, I specify the data using $, it works as expected
adonis2(penguins$bill_length_mm~penguins$species*penguins$island,
        method = "euclidean")
@jarioksa
Copy link
Contributor

This works exactly like documented:

formula: Model formula. The left-hand side (LHS) of the formula must
be either a community data matrix or a dissimilarity matrix,
e.g., from ‘vegdist’ or ‘dist’. If the LHS is a data matrix,
function ‘vegdist’ will be used to find the dissimilarities.
The right-hand side (RHS) of the formula defines the
independent variables. These can be continuous variables or
factors, they can be transformed within the formula, and they
can have interactions as in a typical ‘formula’.

data: the data frame for the independent variables.

In your example bill_length_mm is not among accepted alternatives for the LHS in a formula. Please note, that data will be only used for the variables on the RHS (independet variables).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants