0

I wanted to compute a dissimilary matrix IN R by using the following code.

a <- A[,-c(2,3,4)]
b <- a[-c(201:321), ]
b <- unlist(b)

library(vegan)
PD.dist <- vegdist(b, method = "jaccard", binary = TRUE)
Pd.dist

The software R put the following answer

PD.dist <- vegdist(b, method = "jaccard", binary = TRUE)
Warning messages:
1: In vegdist(b, method = "jaccard", binary = TRUE) :
  you have empty rows: their dissimilarities may be meaningless in method “jaccard”
2: In vegdist(b, method = "jaccard", binary = TRUE) :
  missing values in results

I went in my dataframe to search if i had empty rows by it was not the case What can I do?

Werner Hertzog
  • 2,002
  • 3
  • 24
  • 36
aweman
  • 1
  • 2
  • Your example is not reproducible. What is `A` and what does it contain? – ekstroem Mar 29 '20 at 19:52
  • Difficult to answer without a reproducible example but I would hazard a guess that your input structure is incorrect? A quick look at the documentation says it expects a matrix input and you mentioned you have a dataframe. Double check whether your input structure is correct for what the function expects. Are you inadvertently feeding frame with an ID column that the function does not expect or something like that? – QAsena Mar 29 '20 at 19:52
  • How to check whether my input structure to know if it is correct for what the function expects? – aweman Mar 29 '20 at 21:08
  • What are the asterisks (*) in your code? Those should be triggering error messages. Then `b <- unlist(b)` converts your data frame to a vector. Why are you doing that? At least show us `dim(b)` and tell us about your data. – dcarlson Mar 29 '20 at 23:22
  • There are a few ways to check structure, use `class()`, `typeof()`, and `str()`. Putting your object inside the brackets: `class(df)`. Remember that a dataframe is a type of list so `typeof(df)` will return "list". Use `?` to check the functions documentation (`?vegdist`, or google can have some examples with the documentation). The documentation should tell you what input the function expects. It can also help to create mini dummy datasets of a few rows and columns to check if it works and the output is what you expect. – QAsena Mar 29 '20 at 23:54

0 Answers0