COMPLECS was developed to help make sense of complex systems. It reads data from a number of worksheets in a spreadsheet and generates a diagram according to those specifications. Originally, COMPLECS was developed to visualise a problem during the needs assessment phase of intervention development.

complecs(
  input,
  title = "COMPLECS overview",
  layout = "fdp",
  graph_styling = list(c("outputorder", "edgesfirst", "graph"), c("overlap", "false",
    "graph"), c("fixedsize", "false", "node"), c("fontname", "Arial", "graph"),
    c("fontname", "Arial", "node"), c("fontname", "Arial", "edge"), c("headclip", "true",
    "edge"), c("tailclip", "false", "edge")),
  directed = TRUE,
  outputFile = NULL,
  outputWidth = 1600,
  outputHeight = NULL,
  returnDotOnly = FALSE,
  returnSvgOnly = FALSE,
  returnGraphOnly = TRUE,
  maxLabelLength = 20,
  regExReplacements = opts$get("diagrammerSanitization"),
  silent = opts$get("silent")
)

# S3 method for complecs
print(
  x,
  width = x$input$width,
  height = x$input$height,
  title = DiagrammeR::get_graph_name(x$output$graph),
  ...
)

# S3 method for complecs
print(
  x,
  width = x$input$width,
  height = x$input$height,
  title = DiagrammeR::get_graph_name(x$output$graph),
  ...
)

Arguments

input

Either a link to a Google Sheet, or a path to an Excel file.

title

The title of the COMPLECS graph.

layout

The layout to use; has to be one of the DiagrammeR layout types (dot, neato, circo and twopi).

graph_styling

Additional styling to apply; a list with three-element vectors, where the three elements correspond to, respectively, the attr, value, and attr_type arguments for DiagrammeR::add_global_graph_attrs(). Note that these attributes may override attributes specified in the COMPLECS specification.

directed

Whether to draw directed arrows or not.

outputFile

A character vector where each element is one path (including filename) to write the graph to.

outputWidth, outputHeight

If not NULL, a way to override the width and height when calling complecs to generate a COMPLECS overview.

returnDotOnly

Whether to only return the produced DOT code.

returnSvgOnly

Whether to only return the SVG in a character vector.

returnGraphOnly

Whether to only return the produced graph.

maxLabelLength

The number of characters where to wrap the labels.

regExReplacements

A list of pairs of regular expressions that will be applied to the specifications before generating the ABCD. This can be used to sanitize problematic characters (e.g. ', " and \).

silent

Whether to be chatty or silent.

x

The object to print (i.e. a result of a call to complecs).

width, height

If not NULL, a way to override the width and height when calling print to print a COMPLECS overview.

...

Any additional arguments for the print() method are passed to DiagrammeR::render_graph().

Value

A complecs object that includes the graph and the graph in SVG in output$graph and output$graphSvg.

Details

COMPLECS is a recursive acronym for COMPLECS Organises Multiple Players & Linked Environments using Connected Specifications.

Examples

if (FALSE) {
### Path in the package with example COMPLECS
exampleCOMPLECS <-
  system.file(
    "extdata",
    "COMPLECS-spec-example.xlsx",
    package = "behaviorchange"
  );

behaviorchange::complecs(
  exampleCOMPLECS
);

### Loading that COMPLECS from a google sheet - but note that
### this requires an internet connection!
behaviorchange::complecs(
  paste0(
    "https://docs.google.com/spreadsheets/d/",
    "1WMO15xroy4a0RfpuZ8GhT-NfDoxwS34w9PrWp8rGjjk"
  )
);
}