Skip to contents

specify_clusters algorithmically assigns locations to clusters by grouping them geographically


  trial = trial,
  c = NULL,
  h = NULL,
  algorithm = "NN",
  reuseTSP = FALSE



A CRT object or data frame containing (x,y) coordinates of households


integer: number of clusters in each arm


integer: number of locations per cluster


algorithm for cluster boundaries, with options:

NNNearest neighbour: assigns equal numbers of locations to each cluster
kmeanskmeans clustering: aims to partition locations so that each belongs to the cluster with the nearest centroid.
TSPtravelling salesman problem heuristic: Assigns locations sequentially along a travelling salesman path.

logical: indicator of whether a pre-existing path should be used by the TSP algorithm


A list of class "CRTsp" containing the following components:

geom_fulllist:summary statistics describing the site, and cluster assignments.
trialdata frame:rows correspond to geolocated points, as follows:
xnumeric vector: x-coordinates of locations
ynumeric vector: y-coordinates of locations
clusterfactor: assignments to cluster of each location
...other objects included in the input "CRTsp" object or data frame


The reuseTSP parameter is used to allow the path to be reused for creating alternative allocations with different cluster sizes.

Either c or h must be specified. If both are specified the input value of c is ignored.


#Assign clusters of average size h = 40 to a test set of co-ordinates, using the kmeans algorithm
exampletrial <- specify_clusters(trial = readdata('exampleCRT.txt'),
                            h = 40, algorithm = 'kmeans', reuseTSP = FALSE)