[R] How to extract text contexts after clustering.

Ismail SEZEN sezenismail at gmail.com
Mon May 22 05:08:33 CEST 2017


1- PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
2- PLEASE, first _read_ help for kmeans (?kmeans) function before using function.

> On 22 May 2017, at 05:33, θ ” <yarmi1224 at hotmail.com> wrote:
> 
> hi:
> I need to extract the text contexts of top 1 group after clustering.
> But I have no idea how to sort the cluster size then extract the contexts of top 1 clusters.

There isn’t a _top_ cluster for kmeans algorithm. There are _only_ clusters!

> 
> here is my cluster code:
> 
>> file <- read.csv("SiC CMP.csv", header = TRUE)

We don’t know what is in file$Main.IPC.

>> cluster_k<-length(unique(file$Main.IPC))
>> cl <- kmeans(IPC_Dtm , cluster_k)

What is IPC_Dtm?

> 
> 
> I have tried use��
> 
>> sort(cl$size, decreasing=T)

if you read the documentation, you would know cl$size means the number of points in each cluster. So, why do you sort them?

> [1] 341 107 104  80  51  22  15  11  10   8   8   5   5   5   4   4   4   3   3   2   2
> [22]   2   2   2   2   2   2   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1
> [43]   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1
> 
> But I have no idea how to extract the contexts of top 1 cluster.

If you read the _Value_ section of kmeans documentation, you will have an idea how to extract context by using cl$cluster.

> 
> 
> Eva
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



More information about the R-help mailing list