2016-05-18 34 views
2

Rの多くの機能は、NbClust(など)などのコンソール出力を提供します。出力(例:特定の整数値)を一見しないで取得する方法はありますか出力で?コンソールから読む方法は?NbClustから最適な数のクラスタを取得する

は出力がpackage manualで提供されるサンプルコードから次の出力のようになります想像:

[1] "Frey index : No clustering structure in this data set" 
*** : The Hubert index is a graphical method of determining the number of clusters. 
       In the plot of Hubert index, we seek a significant knee that corresponds to a 
       significant increase of the value of the measure i.e the significant peak in Hubert 
       index second differences plot. 

*** : The D index is a graphical method of determining the number of clusters. 
       In the plot of D index, we seek a significant knee (the significant peak in Dindex 
       second differences plot) that corresponds to a significant increase of the value of 
       the measure. 

******************************************************************* 
* Among all indices:             
* 1 proposed 2 as the best number of clusters 
* 2 proposed 4 as the best number of clusters 
* 2 proposed 6 as the best number of clusters 
* 1 proposed 7 as the best number of clusters 

        ***** Conclusion *****        

* According to the majority rule, the best number of clusters is 4 


******************************************************************* 

私は上記の出力の最後の行から値を取得する方法を?

+0

NO、 'X $ Best.nc'は、各インデックスのために、それぞれの「数のクラスタの」 - 値を含むリストを返します。しかし、これは私が興味を持っているのではなく、最後の行の値を取得したいのです... – Joni

+0

@ zx8754上記のように、私はコンソール出力から情報を取り出す方法を探しています。 'NbClust ) 'であるが、一般的には関数によって生成された出力はR – Joni

+0

である。ありがとうございます@ zx8754 コンソール出力の作業はこれほど普通ではないことを指摘してくれてありがとう、この質問の答えにしたいですか? – Joni

答えて

3

コンソールで出力するのではなく、オブジェクトを操作する方がよいです。任意の「良い」関数は、$または@符号を使用してアクセスできる構造化された出力を返します。オブジェクトの構造を確認するには、str()を使用してください。あなたのケースでは

、私はこれは動作するはずだと思う:

length(unique(res$Best.partition)) 
関連する問題