Reputation: 11
I am trying to run the betadisper function (vegan package) and it returns an error. This is what I do:
hom.cov <- betadisper(morf.dist, sexo)
and it retorns to me this error:
Error in sort.list(y) : 'x' must be atomic for 'sort.list'
Have you called 'sort' on a list?
Then I run to traceback:
traceback()
5: stop("'x' must be atomic for 'sort.list'\nHave you called 'sort' on
a list?")
4: sort.list(y)
3: factor(x)
2: as.factor(group)
1: betadisper(morf.dist, sexo)
When I saw this I tried to convert the vector "sexo" in factor with "as.factor" and then run again, but it returned to me the same error. So I tried to run "betadisper()" with the example use in "Numerical Ecology with R" and give me another error:
env <- read.csv("DoubsEnv.csv", row.names=1)
env.pars2 <- as.matrix(env[, c(1, 9, 10)])
env.pars2.d1 <- dist(env.pars2)
(env.MHV <- betadisper(env.pars2.d1, gr))
Error in x - c : arreglos de dimensón no compatibles
traceback()
2: Resids(vectors[, pos, drop = FALSE], centroids[group, pos, drop =
FALSE])
1: betadisper(env.pars2.d1, gr)
I don't know what could happend. Can anyone help me?
Thanks!
Upvotes: 1
Views: 177
Reputation: 3682
R claims that sexo
is not atomic. This is not the most obvious message, but it means that sexo
is not a simple vector of values, but it may be, say, a data frame or a list. Issue
str(sexo)
and see what you get. If you see text like data.frame
or list
in the output and then a dollar sign ($
) then you don't have a simple structure. For instance, the following output is not an atomic item:
> str(a)
List of 1
$ a: Factor w/ 4 levels "BF","HF","NM",..: 4 1 NA 4 2 2 2 2 2 1 ...
In this case you should use a$a
instead of only a
.
Upvotes: 1