2016-07-26 7 views

答えて

0

cuttree()関数を使用すると、指定された深さ、つまり4または5にツリーをトリミングできます。次に、ツリーをテキストで表示するには、単にprint(tree)を入力します。

# As you had 
train <- read.csv("~/Desktop/R/2014data.csv") 
d <- dist(train, method = "euclidean") # distance matrix 
fit <- hclust(d, method="ward") 
plot(fit) 

# trim the tree, k for number of groups, h for height 
fit.4 = cuttree(fit, h=4) 
fit.5 = cuttree(fit, h=5) 

# print the text or plot 
print(fit.4) 
print(fit.4) 
plot(fit.4) 
plot(fit.5) 
+0

プロットで4つのレベルを表示するにはどうすればよいですか? – Norman

+0

申し訳ありませんが、私は 'cuttree'に間違った引数を指定しました。私は答えを編集した – vincentmajor

関連する問題