Learn R Programming

behaviorchange (version 0.4.0)

complecs: Create a COMPLECS graph

Description

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.

Usage

complecs(
  input,
  title = "COMPLECS overview",
  layout = "neato",
  graph_styling = list(c("outputorder", "nodesfirst", "graph"), c("overlap", "false",
    "graph"), c("fixedsize", "false", "node")),
  directed = TRUE,
  outputFile = NULL,
  outputWidth = NULL,
  outputHeight = NULL,
  returnSvgOnly = FALSE,
  maxLabelLength = 20,
  regExReplacements = list(c("\\\"", "`"), c("\\'", "`"), c("\\\\", "/"))
)

# 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().

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.

returnSvgOnly

Whether to only return the SVG in a character vector.

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 \).

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

Run this code
# NOT RUN {
### Path in the package with example COMPLECS
exampleCOMPLECS <-
  system.file(
    "extdata",
    "COMPLECS-spec-template.xlsx",
    package = "behaviorchange"
  );

behaviorchange::complecs(
  exampleCOMPLECS
);

# }
# NOT RUN {
### 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"
  )
);
# }

Run the code above in your browser using DataLab