vis_epicontacts: Plot epicontacts objects using visNetwork

Description Usage Arguments Value Author(s) See Also Examples

View source: R/vis_epicontacts.R

Description

This function plots epicontacts objects using the visNetwork package. The produced object is an htmlwidget which will need rendering within a web browser.

Usage

1
2
3
4
5
6
vis_epicontacts(x, node_color = "id", label = "id", annot = TRUE,
  node_shape = NULL, shapes = NULL, edge_label = NULL,
  edge_color = NULL, legend = TRUE, legend_max = 10,
  col_pal = cases_pal, NA_col = "lightgrey", edge_col_pal = edges_pal,
  width = "90%", height = "700px", selector = TRUE, editor = FALSE,
  edge_width = 3, ...)

Arguments

x

An epicontacts object.

node_color

An index or character string indicating which field of the linelist should be used to color the nodes.

label

An index, logical, or character string indicating which fields of the linelist should be used for labelling the nodes. Logical will be recycled if necessary, so that the default TRUE effectively uses all columns of the linelist.

annot

An index, logical, or character string indicating which fields of the linelist should be used for annotating the nodes. Logical will be recycled if necessary, so that the default TRUE effectively uses all columns of the linelist.

node_shape

An index or character string indicating which field of the linelist should be used to determine the shapes of the nodes.

shapes

A named vector of characters indicating which icon code should be used for each value node_shape, e.g. c(m = "male", f = "female") if 'm' amd 'f' are values from node_shape. See codeawesome for all available codes.

edge_label

An index or character string indicating which field of the contacts data should be used to label the edges of the graph.

edge_color

An index or character string indicating which field of the contacts data should be used to color the edges of the graph.

legend

A logical indicating whether a legend should be added to the plot.

legend_max

The maximum number of groups for a legend to be displayed.

col_pal

A color palette for the nodes.

NA_col

The color used for unknown group.

edge_col_pal

A color palette for the edges.

width

The width of the output, in html compatible format (e.g. '90%' or '800px').

height

The height of the output, in html compatible format (e.g. '800px').

selector

A logical indicating if the selector tool should be used; defaults to TRUE.

editor

A logical indicating if the editor tool should be used; defaults to FALSE.

edge_width

An integer indicating the width of the edges. Defaults to 3.

...

Further arguments to be passed to visNetwork.

Value

The same output as visNetwork.

Author(s)

Thibaut Jombart ([email protected]) VP Nagraj ([email protected])

See Also

visNetwork in the package visNetwork.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
if (require(outbreaks)) {

## example using MERS outbreak in Korea, 2014
head(mers_korea_2015[[1]])
head(mers_korea_2015[[2]])

x <- make_epicontacts(linelist=mers_korea_2015[[1]],
                       contacts = mers_korea_2015[[2]],
                       directed=TRUE)

## Not run: 
plot(x)
plot(x, node_color = "place_infect")
plot(x, node_color = "loc_hosp", legend_max=20, annot=TRUE)
plot(x, "place_infect", node_shape = "sex",
     shapes = c(M = "male", F = "female"))

plot(x, "sex", node_shape = "sex", shapes = c(F = "female", M = "male"),
     edge_label = "exposure", edge_color = "exposure")

## End(Not run)
}

Example output

Loading required package: outbreaks

epicontacts documentation built on May 2, 2019, 11:29 a.m.