# What object class in adonis R is required as input?

## Issue

This question might sound obvious – but does adonis in R require to have a distance matrix as input data or does it transform it within the function? I have two metric variables (isotope data, all negative but I could use its absolute values instead)? I cannot see this within the adonis code if I view it.

This are my 2 VAR

```
structure(list(`CSIA_fish_EFA_eyes[1:5, 8]` = structure(c(3L,
3L, 3L, 3L, 3L), .Label = c("epilithon", "inverts", "salmonid.eyes"
), class = "factor"), ALA.d13C = c(48, 43, 49, 47, 52), LIN.d13C = c(38,
36, 42, 40, 44)), class = "data.frame", row.names = c(84L, 88L,
92L, 96L, 104L))
```

I do not have a community matrix but I want to check if two groups differ in both of these parameters.

## Solution

It takes a formula, data.frame, and provides some other options. You will have to pick your preferred method.

I just changed some of the names in your data.frame. From a substantive perspective, if you are interested in using the absolute value, you can consider Manhattan distance.

```
df <- structure(list(eyes = structure(c(3L,
3L, 3L, 3L, 3L), .Label = c("epilithon", "inverts", "salmonid.eyes"
), class = "factor"), Ad13C = c(48, 43, 49, 47, 52), Ld13C = c(38,
36, 42, 40, 44)), class = "data.frame", row.names = c(84L, 88L, 92L, 96L, 104L))
m1 <- vegan::adonis(data = df, Ad13C ~ Ld13C, method = "bray" ) # see ?vegan::vegdist
m1
# Call:
# vegan::adonis(formula = Ad13C ~ Ld13C, data = df)
#
# Permutation: free
# Number of permutations: 119
#
# Terms added sequentially (first to last)
#
# Df SumsOfSqs MeanSqs F.Model R2 Pr(>F)
# Ld13C 1 0.0039911 0.0039911 15.15 0.83472 0.05 *
# Residuals 3 0.0007903 0.0002634 0.16528
# Total 4 0.0047814 1.00000
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
m2 <- vegan::adonis(data = df, Ad13C ~ Ld13C, method = "manhattan" )
m2
# Call:
# vegan::adonis(formula = Ad13C ~ Ld13C, data = df, method = "manhattan")
#
# Permutation: free
# Number of permutations: 119
#
# Terms added sequentially (first to last)
#
# Df SumsOfSqs MeanSqs F.Model R2 Pr(>F)
# Ld13C 1 36.1 36.100 16.164 0.84346 0.05 *
# Residuals 3 6.7 2.233 0.15654
# Total 4 42.8 1.00000
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
```

Or, with a matrix as a response

```
df$oth <- rnorm(length(df$Ad13C), 10*df$Ld13C, 10)
m3 <- vegan::adonis(data = df, df[,c("Ad13C","oth")] ~ Ld13C, method = "bray" ) # see ?vegan::vegdist
m3
```

Answered By – SushiChef

**This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 **