add_clusters: add_clusters

Description Usage Arguments Value Examples

View source: R/clustering.R

Description

Add a meta-data variable to a corpus indicating the cluster to which each document belongs.

Usage

1
add_clusters(corpus, clust)

Arguments

corpus

A Corpus object.

clust

A HCPC object resulting from a call to corpus_clustering.

Value

A Corpus object with meta(corpus, "cluster") indicating the cluster of each document.

Examples

1
2
3
4
5
6
7
file <- system.file("texts", "reut21578-factiva.xml", package="tm.plugin.factiva")
corpus <- import_corpus(file, "factiva", language="en")
dtm <- build_dtm(corpus)
res <- corpus_ca(corpus, dtm, ncp=2, sparsity=0.98)
clust <- corpus_clustering(res, 3)
corpus <- add_clusters(corpus, clust)
meta(corpus)

R.temis documentation built on May 13, 2021, 1:08 a.m.