[R] distance matrix as text file - how to import?

From: Hans-Jörg Bibiko <bibiko_at_eva.mpg.de>
Date: Tue, 08 Apr 2008 20:50:53 +0200

Dear all,

I have -hopefully- a tiny problem.

I was sent a text file containing a distance matrix ā la:

2 3

4 5 6

Now I wanted to import these data into a dist object to, let's say, do 'plot(hclust(v))'.

My first naīve approach was to scan the text file in order to get a vector v. Then I did:

class(v) <- "dist"
attr(v, "Size") <- 4

But, of course, I got this:

2 4
3 5 6

I wonder if there's an elegant way to do it. The only way I know of is very very stony one.

I'd be very appreciated for any hint.



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 08 Apr 2008 - 18:54:29 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 08 Apr 2008 - 21:30:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive