Help transforming a dist
On Fri, Dec 23, 2011 at 1:06 AM, Taral <taralx at gmail.com> wrote:
Perfect! combn was the trick I needed. Although I'll probably rbind the stuff instead of building a new frame. :)
You should try rbind() with the small example I gave before you use it on your data. You'll immediately see why I didn't. :)
On Thu, Dec 22, 2011 at 6:48 PM, Sarah Goslee <sarah.goslee at gmail.com> wrote:
I'm not at all sure what you mean with your matrix: is that supposed to be three columns? What about:
fakedata <- data.frame(X=runif(3), Y = runif(3))
rownames(fakedata) <- c("A", "B", "C")
dist(fakedata)
? ? ? ? ?A ? ? ? ? B B 0.8617733 C 0.3813032 0.5124284
data.frame(t(combn(rownames(fakedata), 2)), dist=as.vector(dist(fakedata)))
?X1 X2 ? ? ?dist 1 ?A ?B 0.8617733 2 ?A ?C 0.3813032 3 ?B ?C 0.5124284 Sarah On Thu, Dec 22, 2011 at 7:03 PM, Taral <taralx at gmail.com> wrote:
I'd like to convert a dist into a table/matrix/thingy of the form: A B value A C value B C value (assuming the dist was over 3 names). Is there a way to do this without using a for loop?