Learn R Programming

clugenr

Summary

clugenr is an R implementation of the clugen algorithm for generating multidimensional clusters with arbitrary distributions. Each cluster is supported by a line segment, the position, orientation and length of which guide where the respective points are placed.

How to install

A stable version of the package is available on CRAN and can be installed with the following instruction:

install.packages("clugenr")

Alternatively, install the development version from GitHub with the following command (requires the devtools package):

devtools::install_github("clugen/clugenr")

Documentation

All methods and functions are fully documented and can be queried using the built-in help system. After installation, to access the man pages, invoke the clugenr help page as follows:

help("clugenr")

The complete online documentation is available here.

Quick start

library(clugenr)
x <- clugen(2, 5, 1000, c(1, -0.5), 0.5, c(4, 6), 6, 0.2, 0.5)
plot(x$points, col = x$clusters, xlab = "x", ylab = "y", asp = 1)

library(clugenr)
library(rgl) # For 3D plots
x <- clugen(3, 5, 2000, c(1, 0.5, -0.7), 0.5, c(15, 10, 20), 15, 3, 10)
plot3d(x$points, col = x$clusters, xlab = "x", ylab = "y", zlab = "z", aspect = T)

See also

  • pyclugen, a Python implementation of the clugen algorithm.
  • CluGen.jl, an Julia implementation of the clugen algorithm.
  • MOCluGen, a MATLAB/Octave implementation of the clugen algorithm.

Reference

If you use this software, please cite the following reference:

License

MIT License

Copy Link

Version

Install

install.packages('clugenr')

Monthly Downloads

151

Version

1.0.4

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Nuno Fachada

Last Published

July 7th, 2025

Functions in clugenr (1.0.4)

gdim

Returns the actual dimensions of the input
rand_ortho_vector

Get a random unit vector orthogonal to u.
llengths

Determine length of cluster-supporting lines
fix_empty

Certify that, given enough points, no clusters are left empty
rand_vector_at_angle

Get a random unit vector at a given angle with another vector.
rand_unit_vector

Get a random unit vector with num_dims components.
fix_num_points

Certify that array values add up to a specific total
angle_deltas

Get angles between average cluster direction and cluster-supporting lines
clupoints_n

Create points from their projections on a cluster-supporting line
clupoints_n_1

Create points from their projections on a cluster-supporting line
clumerge

Merges the fields (specified in fields) of two or more data sets
clucenters

Determine cluster centers using the uniform distribution
clugenr-package

clugenr: Multidimensional Cluster Generation Using Support Lines
clupoints_n_1_template

Create points from their projections on a cluster-supporting line
angle_btw

Angle between two n-dimensional vectors.
clusizes

Determine cluster sizes, i.e., the number of points in each cluster
clugen

Generate multidimensional clusters
tprom

Generality of types, by increasing order
points_on_line

Determine coordinates of points on a line