-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtreemap_trelliscope.R
36 lines (29 loc) · 1006 Bytes
/
treemap_trelliscope.R
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
35
36
#' Create Treemap Trelliscopes
#'
#' @param data dataframe to be turned into sankey trelliscope. Ensure that columns are in the order that the sankey
#' nodes should be left to right
#' @param facet column of variables that you want the trelliscope to group on.
#' @param quant_variable column containing the numeric values for the links between nodes.
#'
#' @return Trelliscope Display
#' @export
#'
#' @examples
#'
#' treemap_trelliscope(data = dat, facet = "state_company", quant_variable = "amount_award")
#'
treemap_trelliscope <- function(data, facet, quant_variable, title = "Treemap", path = "~treemap"){
dat <- data
dat <- suppressWarnings(nest(dat, -facet))
dat <- dat %>%
mutate(dat_plot = map2_plot(data, quant_variable, plot_treemap))
trel_treemap <- dat %>%
drop_na() %>%
trelliscope(name=title,
path = path,
thumb = T,
nrow = 1,
ncol = 2
)
trel_treemap
}