plot_org: Simple organisation plot

Description Usage Arguments Details Value Examples

Description

Bare bones function to plot an organisation style dendrogram from a tidygraph object.

Usage

1
2
plot_org(x, fill_var = "org_depth", df = NULL, is_circular = FALSE,
  is_dendrogram = TRUE, return_tbl_graph = FALSE)

Arguments

x

organisation as a tidygraph object (tidygraph)

fill_var

the variable to use as a fill colour for units. Will either be a metric_id in df or a column in the nodes data frame in the tidygraph object (metric name)

df

a data frame in org_tall_df format ie summarised metrics for the units in the network as generated by calc_summary_df. See orgsurveyr-data-formats for more information. If NULL the fill_var comes from the nodes data frame in the tidygraph object (data frame)

is_circular

whether to make the network circular which is useful for larger organisations (logical)

is_dendrogram

whether to make the network a dendrogram or an icicle/starburst plot (logical)

return_tbl_graph

whether to return the constructed tbl_graph object rather than the plot. This can be useful if a different plot needs to be constructed to that provided. Default FALSE (logical)

Details

Note that the recommended way to plot organisations is using the ggraph package. Some examples of how to do this are included in the vignettes. This simple function is provided as a convenience for new users and to use in examples.

DEV NOTE: in ggplot2 version 3.0.0 tidyeval is available so should be able to use this rather than aes_string

Value

ggraph object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
library(tidygraph)
library(dplyr)
library(ggraph)

set.seed(1236)
tg2 <- create_realistic_org(4,3, prob=0.3, delete_units = TRUE) %>%
   simulate_unit_size
tg2

# plot the organisation using the depth of the unit in the organisation as fill colour
## Not run: 
plot_org(tg2, fill_var='org_depth') #normal dendrogram
plot_org(tg2, fill_var='org_depth', is_circular=TRUE) #circular dendrogram

# build on ggraph object using ggraph functionality - ie add unit sizes
plot_org(tg2, fill_var='org_depth') + geom_node_text(aes(label=unit_size), color='white')

## End(Not run)

# can also include aggregated unit information from calc_summary_df

# simulate individual data and summarise
tg2_indiv_df <- tg2 %>%
   simulate_individuals_df() %>%
   mutate(test_var2 = purrr::map_dbl(individual_id, ~rnorm(1, 20,3)))

summary_df <- calc_summary_df(tg2, tg2_indiv_df, NULL, c('test_var', 'test_var2'), TRUE)

# plot the organisation using the cumulative mean of the individual variables
## Not run: 
plot_org(x=tg2, fill_var = 'test_var', df=summary_df)
plot_org(x=tg2, fill_var = 'test_var2', df=summary_df)

## End(Not run)

ukgovdatascience/orgsurveyr documentation built on May 4, 2019, 7:41 p.m.