Learn R Programming

About

An R package designed to enable researchers to quickly and efficiently generate customized sets of keywords.

For more information about the methods underlying this package see Chester (2025).

Installation

Install the package from CRAN:

install.packages("keyclust")

Or install the development version from GitHub:

install.packages("devtools") # If not already installed

devtools::install_github("pchest/keyclust")

Usage

Creating a cosimilarity matrix from a pre-fitted word embeddings model

library(keyclust)

simmat <- wordemb_FasttextEng_sample |>
    process_embed(words = "words") |>
    similarity_matrix(words = "words")

Extracting a semantically-related set of keywords from a cosimilarity matrix

seed_months <- c("october", "november")

out_months <- keyclust(simmat, seed_words = seed_months, max_n = 10)
## Initializing with october, november 
## Added september 
## Added august 
## Added february 
## Added january 
## Added december 
## Added march 
## Added april 
## Added june
out_months |>
  terms() |>
  head(n = 10)
##         Term Group_similarity
## 1    october        0.9764174
## 2   february        0.9727986
## 3  september        0.9715995
## 4    january        0.9695413
## 5   november        0.9693111
## 6     august        0.9677877
## 7      march        0.9673854
## 8      april        0.9653796
## 9       june        0.9625061
## 10  december        0.9609312

Copy Link

Version

Install

install.packages('keyclust')

Monthly Downloads

197

Version

1.2.5

License

GPL-3

Maintainer

Patrick Chester

Last Published

June 3rd, 2025

Functions in keyclust (1.2.5)

print.keyclust

Prints terms generated by keyclust
wordemb_FasttextEng_sample

Sample from the pre-trained English fastText model
similarity_matrix

Algorithm designed to create a cosine similarity matrix from a fitted word embedding model
keyclust

Algorithm designed to efficiently extract keywords from a cosine similarity matrix
cosimilarity_matrix

Returns cosine cosimilarity matrix for the terms generated by keyclust
process_embed

A tool designed to reduce redundant terms in a fitted embedding model
terms.keyclust

Returns terms generated by keyclust