[R] Extracting metadata information to corresponding dissimilarity matrix

Rune Grønseth nielsenrune at me.com
Tue May 16 11:30:30 CEST 2017

I am R beginner. I've tried googling and reading, but this might be too simple to be found in the documentation. 

I have a dissimilarity index (symmetric matrix) from which I have extracted the unique values using the exodist package command "lower". There are 14 observations, so there are 91 unique comparisons.

After this I'd like to extract corresponding metadata from a separate data frame (the 14 observations organized in rows identified by a samplenumber-vector, and other variables as gender, age, et cetera). The aim is to have a new data frame with 91 rows and metadata vectors giving me the value of the dissimilarity index,  gender each of the two observations that are compared by the dissimilarity metric. So if I'm looking for gender differences, I need 5 vectors in the data frame: samplenumber1, samplenumber2, gender1, gender2 and dissimilarity metric.

Does anyone have suggestions or experiences in reformatting data in this manner? This is just a test-dataset. My full data-set is for more than 100 observations, so I need a more general code, if that is possible.

With great appreciation of any help.

Rune Grønseth 


Rune Grønseth, MD, PhD, postdoctoral fellow
Department of Thoracic Medicine
Haukeland University Hospital
N-5021 Bergen

	[[alternative HTML version deleted]]

More information about the R-help mailing list