Description Usage Arguments Details Value Examples
Takes an organisation as a tbl_graph object and a data frame that maps individuals to units and returns a data frame that maps an organisational unit to all individuals within that unit.
1 |
tg |
tbl_graph that passes a check with check_tbl_graph_is_org |
df |
a data frame with columns named unit_id and invididual_id - see see the indiv_df format
in |
For example, if an organisation is split into four departments, and each department has four teams, an employee is affiliated not just to their immediate team, but also their department and the organisation as a whole.
The output dataframe serves as a basis for calculating unit level summaries that include all individuals affiliated to that unit.
tbl_df
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | library(dplyr)
set.seed(1234)
tg_ex1 <- create_realistic_org(n_children = 4, max_depth = 3, prob=0.3)
tg_ex1 <- simulate_unit_size(tg_ex1)
df <- simulate_individuals_df(tg_ex1)
map_df <- generate_cumulative_mapping(tg_ex1, df)
map_df
#use the map to calculate cumulative means
df %>%
inner_join(map_df, by='individual_id') %>%
group_by(parent_id) %>%
summarise(cum_test_var = mean(test_var),
cum_n = n())
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.