as.dist() を使えばいいらしい.
例えば,以下の距離行列が書かれたcsvファイルがあったとする.
hoge.csv
-----------
a, b, c, d
0,,,
1,0,,
2,3,0,
4,5,6,0
------------
これを R で処理するには,
1.
> x <- read.table("hoge.csv", sep=",", header=TRUE)
> plot(hclust(as.dist(x)))
2.
> x <- matrix(scan("hoge.csv", sep=",", skip=1), ncol=4, byrow=TRUE)
> plot(hclust(as.dist(x)))
1と2の結果は同じ.
しかし,2の方法は左にキーがある場合は無理.左にある場合,
> x <- read.table("hoge.csv", sep=",", header=TRUE, row.names=1)
例えば,以下の距離行列が書かれたcsvファイルがあったとする.
hoge.csv
-----------
a, b, c, d
0,,,
1,0,,
2,3,0,
4,5,6,0
------------
これを R で処理するには,
1.
> x <- read.table("hoge.csv", sep=",", header=TRUE)
> plot(hclust(as.dist(x)))
2.
> x <- matrix(scan("hoge.csv", sep=",", skip=1), ncol=4, byrow=TRUE)
> plot(hclust(as.dist(x)))
1と2の結果は同じ.
しかし,2の方法は左にキーがある場合は無理.左にある場合,
> x <- read.table("hoge.csv", sep=",", header=TRUE, row.names=1)