MyNixOS website logo
Description

The Reinert Method for Textual Data Clustering.

An R implementation of the Reinert text clustering method. For more details about the algorithm see the included vignettes or Reinert (1990) <doi:10.1177/075910639002600103>.

Rainette

CRAN status rainette status badge DOI CRAN Downloads R build status

Rainette is an R package which implements a variant of the Reinert textual clustering method. This method is available in other softwares such as Iramuteq (free software) or Alceste (commercial, closed source).

Features

  • Simple and double clustering algorithms
  • Plot functions and shiny interfaces to visualise and explore clustering results
  • Utility functions to split a corpus into segments or import a corpus in Iramuteq format

Installation

The package is installable from CRAN.

install_packages("rainette")

The development version is installable from R-universe.

install.packages("rainette", repos = "https://juba.r-universe.dev")

Usage

Let's start with an example corpus provided by the excellent quanteda package.

library(quanteda)
data_corpus_inaugural

First, we'll use split_segments() to split each document into segments of about 40 words (punctuation is taken into account).

corpus <- split_segments(data_corpus_inaugural, segment_size = 40)

Next, we'll apply some preprocessing and compute a document-term matrix with quanteda functions.

tok <- tokens(corpus, remove_punct = TRUE)
tok <- tokens_remove(tok, stopwords("en"))
dtm <- dfm(tok, tolower = TRUE)
dtm <- dfm_trim(dtm, min_docfreq = 10)

We can then apply a simple clustering on this matrix with the rainette() function. We specify the number of clusters (k), and the minimum number of forms in each segment (min_segment_size). Segments which do not include enough forms will be merged with the following or previous one when possible.

res <- rainette(dtm, k = 6, min_segment_size = 15)

We can use the rainette_explor() shiny interface to visualise and explore the different clusterings at each k.

rainette_explor(res, dtm, corpus)

rainette_explor() interface

The Cluster documents tab allows to browse and filter the documents in each cluster.

rainette_explor() documents tab

We can also directly generate the clusters description plot for a given k with rainette_plot().

rainette_plot(res, dtm, k = 5)

Or cut the tree at chosen k and add a group membership variable to our corpus metadata.

docvars(corpus)$cluster <- cutree(res, k = 5)

In addition to this, we can also perform a double clustering, ie two simple clusterings produced with different min_segment_size which are then "crossed" to generate more robust clusters. To do this, we use rainette2() on two rainette() results :

res1 <- rainette(dtm, k = 5, min_segment_size = 10)
res2 <- rainette(dtm, k = 5, min_segment_size = 15)
res <- rainette2(res1, res2, max_k = 5)

We can then use rainette2_explor() to explore and visualise the results.

rainette2_explor(res, dtm, corpus)

rainette2_explor() interface

Tell me more

Two vignettes are available :

Credits

This clustering method has been created by Max Reinert, and is described in several articles, notably :

Thanks to Pierre Ratineau, the author of Iramuteq, for providing it as free software and open source. Even if the R code has been almost entirely rewritten, it has been a precious resource to understand the algorithms.

Many thanks to Sébastien Rochette for the creation of the hex logo.

Many thanks to Florian Privé for his work on rewriting and optimizing the Rcpp code.

Metadata

Version

0.3.1.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows