Euclidean dissimilarity matrix

I am converting my data into a Euclidean dissimilarity matrix but I have a problem.
I have multiple response variables and when I run the matrix with all my data, including all response variables, it gives me an output but I have no idea which response variable the output is for. I ended up creating separate csv files for each individual response variable so that when I run the matrix, I know what the output is for. However, I was wondering if there was a simpler way, possibly including something in the vegdist code so that it only uses a certain column and I can distinguish between each variable.

For example,
I tried using the data frame with ALL my response variables and included an argument to call out only one column "LT_R"
vegdist(T_data ~ LT_R, method="euclidean", binary=FALSE, diag=FALSE, upper=FALSE, na.rm=FALSE
but that gave me an error.

I also tried the same thing with a comma instead of a ~
vegdist(T_data, LT_R, method="euclidean", binary=FALSE, diag=FALSE, upper=FALSE, na.rm=FALSE
and it gave me an output but when I compared the numbers it gave me from this (all my data) compared to the csv file I have that ONLY contains the response variable LT_R the numbers did not match so I'm assuming the argument didn't work.

I basically just need a simpler way to run the matrix on all my response variables separately while keeping my data frame whole with all my data.

Any help is appreciated!! Thank you.

I had a quick look at the documentation for vegan::vegdist
It has no formula type parameter that would accept ~ neither does it have a parameter for emphasising any particular variable.
I think if you want to pair down the size of the matrix a call to vegdist will process you would do upfront work to select the relevant columns. Here is an example of how I might do that, not for vegdist (which I don't know the ins and outs of) but a cor() function call , as example. lets say I have iris dataset with 4 numeric columns, but I want the correlation of one column in particular against each of the other 3, done seperately. I could do the following :

(iris_m <- as.matrix(iris[1:10,1:4]))


my_resp <- "Sepal.Length" 

(namepairs <- map(setdiff(colnames(iris_m),my_resp),

(paired_matrices <- map(namepairs,

(done_some_funcs <- map(paired_matrices,

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.