plotCRT {CRTspat}R Documentation

Graphical displays of the geography of a CRT


plotCRT returns graphical displays of the geography of a CRT or of the results of statistical analyses of a CRT


  map = FALSE,
  distance = "nearestDiscord",
  fill = "arms",
  showLocations = FALSE,
  showClusterBoundaries = TRUE,
  showClusterLabels = FALSE,
  showBuffer = FALSE,
  cpalette = NULL,
  buffer_width = NULL,
  maskbuffer = 0.2,
  labelsize = 4,
  legend.position = NULL



object of class 'CRTanalysis' produced by CRTanalysis()


logical: indicator of whether a map is required


measure of distance or surround with options:

"nearestDiscord" distance to nearest discordant location (km)
"disc" disc
"hdep" Tukey's half space depth
"sdep" simplicial depth

fill layer of map with options:

'cluster' cluster assignment
'arms' arm assignment
'nearestDiscord' distance to the nearest discordant location
'disc' disc measure of surround
'hdep' Tukey's half space depth
'sdep' simplicial depth
'prediction' model prediction of the outcome
'none' No fill

logical: determining whether locations are shown


logical: determining whether cluster boundaries are shown


logical: determining whether the cluster numbers are shown


logical: whether a buffer zone should be overlayed


colour palette (to use different colours for clusters this must be at least as long as the number of clusters.


width of buffer zone to be overlayed (km)


radius of buffer around inhabited areas (km)


size of cluster number labels


(using ggplot2::themes syntax)


If map = FALSE and the input is a trial data frame or a CRTsp object, containing a randomisation to arms, a stacked bar chart of the outcome grouped by the specified distance is produced. If the specified distance has not yet been calculated an error is returned.

If map = FALSE and the input is a CRTanalysis object a plot of the estimated spillover function is generated. The fitted spillover function is plotted as a continuous blue line against the measure the surround or of the distance to the nearest discordant location. Using the same axes, data summaries are plotted for ten categories of distance from the boundary. Both the average of the outcome and confidence intervals are plotted.

If map = TRUE a thematic map corresponding to the value of fill is generated.

If showBuffer = TRUE the map is overlaid with a grey transparent layer showing which areas are within a defined distance of the boundary between the arms. Possibilities are:

A message is output indicating which of these possibilities applies.


graphics object produced by the ggplot2 package


{example <- readdata('exampleCRT.txt')
#Plot of data by distance
#Map of locations only
plotCRT(example, map = TRUE, fill = 'none', showLocations = TRUE,
           showClusterBoundaries=FALSE, maskbuffer=0.2)
#show cluster boundaries and number clusters
plotCRT(example, map = TRUE, fill ='none', showClusterBoundaries=TRUE,
           showClusterLabels=TRUE, maskbuffer=0.2, labelsize = 2)
#show clusters in colour
plotCRT(example, map = TRUE, fill = 'clusters', showClusterLabels = TRUE,
          labelsize=2, maskbuffer=0.2)
#show arms
plotCRT(example, map = TRUE,
fill = 'arms', maskbuffer=0.2, legend.position=c(0.8,0.8))
#spillover plot
analysis <- CRTanalysis(example)
 plotCRT(analysis, map = FALSE)

[Package CRTspat version 1.2.0 Index]