# devtools::load_all();devtools::document();pkgdown::build_site(lazy=F)

options(dplyr.summarise.inform = FALSE)
library(CausalMapFunctions)
library(knitr)
library(htmltools)
library(configr)
library(dbplyr)
library(DBI)
library(kableExtra)
library(scales)
knitr::opts_chunk$set(echo = T,warning=F,message=F)
#source("../R/functions.R")################################
 config = configr::read.config("../config.yml")$default

 conn <- dbConnect(
   drv = RMySQL::MySQL(max.con=100, fetch.default.rec=1000),
   dbname = "cm2assets",
   host = config$sql$host,
   port = config$sql$port,
   username = config$sql$username,
   password = config$sql$password
 )

pp=function(x,N=99){
  print(x,n=N)
}

replace_null <- function(x,replacement=0){
  if(is.null(x)) replacement else x
}


append_rows <- function(val,name){
  val <- val %>% mutate_all(clean_send)
  dbWriteTable(con=conn,name = local(name),value=local(val) ,append=TRUE,row.names=FALSE)
}
print_inner_filter <- function(xx){
  # browser()
xx$graf <- NULL
fil <- xx[[1]] %>% unlist %>% str_remove_all("^pipe_") %>% str_replace("_"," ")
xx <- xx[-1]
nams=names(xx)
tibble(names=nams,vals=unlist(xx)) %>% 
  unite(filter,sep="=") %>% 
  pull(filter) %>% 
  unlist %>% 
  paste0(.,collapse=" ") %>% 
  paste0(fil," ",.)
}
print_filter <- function(graf){

  if(!exists("xtitle"))xtitle <- ""
  if(!exists("xdescription"))xdescription <- ""

  if(is.null(attr(graf,"info")))return()
  # browser()
story <- attr(graf,"info")[[1]] %>% keep(~str_detect(.,"^load_mapfile")) %>% unlist %>% str_remove("load_mapfile *path=")
input_ace <- attr(graf,"info") %>% list_modify("load_mapfile" = NULL) %>% unlist %>% keep(.!=".") %>% map(~str_remove_all(.,"^pipe_") %>% str_replace("_"," ")) %>%  paste0(collapse = "\n")
filters <- paste0("&filters=",URLencode(input_ace %>% replace_null(""),reserved=T))

message("appending")
append_rows(
  tibble(likes=1,recommended=T,filter=input_ace %>% replace_null(""),hidden=F,title=xtitle %>%    replace_null(""),description=xdescription %>% replace_null(""),date=time_stamp(),project=story)
  ,"shortlinks")


attr(graf,"info") %>% 
  map(~print_inner_filter(.) %>% 
      str_trim %>% 
      div(style=";")
  ) %>%  tagList %>% div(style="padding:10px;background-color:aliceblue;") %>% div(
    if(xtitle!="")h5(xtitle),
    if(xdescription!="")p(xdescription),                                                                     
    .,
    a("Link",href=paste0("https://causalmap.shinyapps.io/CausalMap2?story=",story,filters)),style="padding:10px;background-color:aliceblue;")


}

# make_interactive_map <- function(graf){
#   tagList(print_filter(graf),CausalMapFunctions::make_interactive_map(graf))
# }
# make_print_map <- function(graf){
#   tagList(print_filter(graf),CausalMapFunctions::make_print_map(graf))
# }
clean_send <- function(vec){
  if(vec %>% unique %>% `%in%`(c(F,T)) %>% all) vec <- as.numeric(vec)
  if(F & is.character(vec)) {
    # Encoding(vec)="UTF-8"
    vec <- stri_enc_toascii(vec)
  }
  vec
}

You might need to wait a few seconds for all of the graphics in this file to load.

How it works

You import a mapfile from a built-in example file, a local excel file, from a S3 store, or from sql using load_mapfile()

A family of functions pipe_* are provided (manipulate, calculate, hide, combine...) to implement successive filtering operations on a mapfile. These operations do not change the underlying data.

So you import/load data as a mapfile and all your work steps are then just applying successive filters.

Each filter returns another mapfile, suitably filtered.

Mapfiles, which are just lists of tables (actually, tibbles) with the class mapfile.

Statement tables are used in Causal Map as the underlying data which is to be coded into causal links. So each link refers to a quote from a particular statement. Statements are optional and this package can be used without them.

In this package, nodes are called factors and the edges are called links.

Parser

All of these filters can be produced and edited either in a chain of actual R functions or in the simplified text format which is processed by the parser: parse_commands.

This parser takes text strings with a simpler command syntax as input and outputs one of these main functions for each line of text. This parser is used to read text commands from the input window in Causal Map Viewer and manipulate the output map with the corresponding functions. The input text can also consist of several lines, and the commands are applied one by one in sequence, in a pipeline of commands, such that after each command, such as each command starts with the map defined by the previous line and produces a new one.

Output functions

There are three output functions which are thin wrappers around visNetwork, DiagrammeR and DT, allowing a graph to be displayed using any of these three visualisation engines.

Additional fields

Some of the commands such as path tracing create additional fields or variables for each factor and/or link. For example, when filtering by label, fields are created which can then be used to apply formatting.

Loading example datasets

(After loading CausalMapFunctions library)

The package ships with some example datasets, at the moment just these:

which you can also view in Causal Map on the web.

Visualise the files like this:

example2 %>% pipe_coerce_mapfile() %>% make_interactive_map

Your input mapfile should have the standard Causal Map format: you can see an example by downloading any of the files in Causal Map on the web.

pipe_coerce_mapfile will also process a file with no factors and from_label and to_label columns as a named edgelist.

factor ids are no longer contiguous, pipe normalise factors links now just deletes links with no factors.

# ll <- quip_example
  # ee <- example2
  ee <- load_mapfile("example2") %>% pipe_recalculate_all()

Basic examples

Interactive and Print maps

xtitle <- "Interactive"
xdescription <- ""
  ee %>%
    pipe_label_links("link_id",fun = "unique") %>%
    make_interactive_map

xtitle <- "Print"
  ee %>%
    pipe_label_links("link_id",fun = "unique") %>%
    make_print_map()

xdescription <- "Set a different print layout"
  ee %>%
    pipe_set_print(grv_layout="circo") %>%
    make_print_map()

More examples

ef <- load_mapfile("example-file")%>% pipe_coerce_mapfile 
hz <- load_mapfile("health-zoom")%>% pipe_coerce_mapfile 
  cg <- load_mapfile("oicanadaghana22")%>% pipe_coerce_mapfile 
  sz <- load_mapfile("smartzoomingexample")%>% pipe_coerce_mapfile 
  kh <- load_mapfile("kantar-hierarchy-test-sp")%>% pipe_coerce_mapfile 
  ks <- load_mapfile("kantar-swan-short")%>% pipe_coerce_mapfile 
  so <- load_mapfile("stress-opposites")%>% pipe_coerce_mapfile 
  tt <- load_mapfile("tearfund-sl-small")%>% pipe_coerce_mapfile
  ll <- load_mapfile("quip-coded")%>% pipe_coerce_mapfile
  oi <- load_mapfile("2oirefugeetestimonies")%>% pipe_coerce_mapfile
  oo <- load_mapfile("organisation1coded")%>% pipe_coerce_mapfile
  e3 <- load_mapfile("example3-path-tracing")%>% pipe_coerce_mapfile
  mm <- load_mapfile("save-the-children-mozambique-copy")%>% pipe_coerce_mapfile
  hh <- load_mapfile("hannahcombiningopposites-sp-test")%>% pipe_coerce_mapfile
  oi <- load_mapfile("2oirefugeetestimonies")%>% pipe_coerce_mapfile
  oh <- load_mapfile("oh1-sp2")%>% pipe_coerce_mapfile
  cc <- load_mapfile("coded-quip-training")%>% pipe_coerce_mapfile
  de <- load_mapfile("dimensions-example")%>% pipe_coerce_mapfile
  ma <- load_mapfile("concern-2022-malawi")%>% pipe_coerce_mapfile
  pa <- load_mapfile("pilotabcdwellbeing-2022")%>% pipe_coerce_mapfile
  oig <- load_mapfile("oi-2021-ghana")%>% pipe_coerce_mapfile


# ef %>% parse_commands("zoom factors level=1
# find factors field=factor_memo value=Agriculture operator=contains up=0 down=0
#                       ")  %>% 
#   make_mentions_tabl() %>% 
#   pull(`#Name of province`) %>% 
#   table(useNA = "al")

Selecting and finding

If you filter the factors of a mapfile, e.g. show only factors with labels beginning xyz,

If you filter the links of a mapfile, e.g. show only links with hashtags containing xyz,

If you filter the statements of a mapfile, e.g. show only statements with texts containing xyz,

ll %>%
    pipe_select_factors(15) %>%
    make_interactive_map

ll %>%
    pipe_select_factors(15) %>%
    make_interactive_map

Simple frequency

ll %>%
    pipe_find_links("simple_frequency",value = 50,"greater") %>%
    make_interactive_map
ll %>%
    pipe_select_links(5) %>%
    make_interactive_map
ll %>%
    pipe_find_statements(field="statement_id",value=5,operator="equals") %>%
    make_interactive_map
ee %>%
    pipe_find_factors(field="factor_memo",value="memo",operator="equals") %>%
    make_interactive_map
ll %>%
    pipe_find_factors(value="economic") %>%
    make_interactive_map

Showing interlinks or not

If you don't want to show interlinks between downstream factors, use find links instead.

oo %>%
  pipe_find_factors(value="more/better seeds",up=0,down=1,remove_isolated = T) %>%
    pipe_bundle_links() %>% 
    make_print_map

oo %>%
  pipe_find_links(value="more/better seeds",field="from_label",operator="contains") %>%
    pipe_bundle_links() %>% 
    make_print_map

Zero up and down

ee %>%
    pipe_find_factors(value="rainfall",up=0,down=0,remove_isolated = T) %>%
    make_interactive_map
ee %>%
    pipe_find_factors(value="rainfall",up=0,down=0,remove_isolated = F) %>%
    make_interactive_map

Case insensitive

ee %>%
    pipe_find_factors(value="business") %>%
    make_interactive_map

notcontains

ee %>%
    pipe_find_factors(value="sea",operator="notcontains") %>%
    make_interactive_map
ee %>% pipe_find_statements(value="1",operator="notcontains",field="statement_id")%>%
    make_interactive_map
ee %>% pipe_find_statements(value="1",operator="notcontains",field="statement_id")%>%
    make_interactive_map

notequals

ee %>% pipe_find_statements(value="1",operator="notequals",field="statement_id")%>%
    make_interactive_map
ee %>%
    pipe_find_factors(value="Coastal erosion",operator="notequals") %>%
    make_interactive_map

OR

Does not work in functions, but works when parsed:

ee %>%
    pipe_find_factors(value="business OR property") %>%
    make_interactive_map
ee %>%
    parse_commands("find factors field=label operator=contains value=Business OR Property") %>%
    make_interactive_map

Order matters

ll %>%
    pipe_find_factors(value="economic") %>%
    pipe_select_factors(5) %>%
    make_interactive_map

No result

ll %>%
    pipe_find_factors(value="asdfasdfasdf") %>%
    make_interactive_map
ll %>%
    pipe_find_links(field="from_label",value="economic",operator="contains") %>%
    make_interactive_map

Numerical comparison

ll %>%
    pipe_find_statements(field="statement_id",value=20,operator="less") %>%
    make_interactive_map

No result

ll %>%
    pipe_find_statements(field="statement_id",value=20000000,operator="greater") %>%
    make_interactive_map

Highlight only

e3  %>% 
  pipe_find_factors(value="Damage",highlight_only=T) %>% pipe_color_factors(field="found") %>% 
  make_interactive_map()

Note this doesn't work in the app:

e3  %>% 
  pipe_find_links(field="from_label",value="Damage",highlight_only=T) %>%     
  pipe_color_links(field="found",fun="literal") %>% 
  make_interactive_map()

Clustering sources

pipe_cluster_sources(oi)

Calculated fields

oi %>% 
  pipe_find_factors(value="Take a loan",up = 1,down=1) %>% 
  make_mentions_tabl()
oi %>% 
  pipe_find_factors(value="Take a loan",up = 1,down=1) %>% 
.$factors %>% select(label,source_count)

Conditional formatting

ll %>%
    pipe_select_factors(5) %>%
    pipe_scale_factors(field="frequency") %>%
    make_interactive_map

ll %>%
    pipe_select_factors(5) %>%
    pipe_color_text(field="frequency") %>%
    make_interactive_map

ll %>%
    pipe_select_factors(5) %>%
    pipe_scale_factors(field="frequency") %>%
    make_print_map
ll %>%
    pipe_select_factors(5) %>%
    pipe_color_factors(field="frequency") %>%
    pipe_color_borders(field="betweenness") %>%
    pipe_wrap_factors(5) %>%
    make_interactive_map

Wrap factors

ll %>%
    pipe_select_factors(5) %>%
    pipe_color_links(value="count: link_id") %>%
    pipe_wrap_factors(5) %>%
    make_interactive_map
ll %>%
    pipe_select_factors(5) %>%
    pipe_color_links(value="count: link_id") %>%
    pipe_wrap_factors(5) %>%
    make_print_map

Wrap links

ee %>%
    pipe_label_links("from_label",fun = "unique") %>%
    pipe_wrap_links(6) %>%
    make_interactive_map

ee %>%
    pipe_label_links("from_label",fun = "unique") %>%
    pipe_wrap_links(6) %>%
    make_print_map
ee %>%
    pipe_label_links(value="unique: from_label") %>%
    pipe_wrap_links(6) %>%
    make_interactive_map
ll %>%
    make_interactive_map

Remove brackets

ll %>%
    pipe_select_factors(5) %>%
    pipe_remove_brackets() %>%
    make_interactive_map

Self loops

ks %>% 
  parse_commands("find factors field=label value=~People feeling safe operator=notcontains up=4 down=1
find factors field=label value=People feeling safe operator=contains up=4 down=1
zoom factors level=2
remove isolated
find links field=source_frequency value=2 operator=greater
remove selfloops
hide quickfields
bundle links field=simple_bundle
label factors field=source_count add_field_name=FALSE clear_previous=FALSE
scale links value=count: source_id
label links value=count: source_id
wrap factors length=40
color text field=is_opposable lo=black hi=#f26d04
color factors field=found lo=white hi=#7FC97F") %>% 
  make_print_map()

ef %>% 
  parse_commands("find factors field=label value=Health=contains up=4 down=1
zoom factors level=2
remove isolated
find links field=source_frequency value=2 operator=greater
remove selfloops
hide quickfields
bundle links field=simple_bundle
label factors field=source_count add_field_name=FALSE clear_previous=FALSE
scale links value=count: source_id
label links value=count: source_id
wrap factors length=40
color text field=is_opposable lo=black hi=#f26d04
color factors field=found lo=white hi=#7FC97F") %>% 
  make_print_map()

Bundle factors

ll %>%
    pipe_bundle_factors(value = "IEA") %>%
    pipe_select_factors(5) %>%
    make_interactive_map

Format links without bundling

ee %>%
  pipe_color_links("link_id",fun = "mean") %>%
  make_interactive_map
ee %>%
  pipe_scale_links("link_id",fun = "mean") %>%
  make_interactive_map

Label factors with and without field names

cc %>%
  pipe_find_factors(value="Improved health") %>% 
    # pipe_zoom_factors(1) %>%
  pipe_select_factors(top=10) %>% 
  pipe_bundle_links(field="simple_bundle") %>% 
  pipe_label_links(field="source_id",fun = "count") %>% 
  pipe_label_factors(field="source_count",add_field_name = F) %>% 
  pipe_wrap_factors() %>% 
    make_print_map 

cc %>%
  pipe_find_factors(value="Improved health") %>% 
    # pipe_zoom_factors(1) %>%
  pipe_select_factors(top=10) %>% 
  pipe_bundle_links(field="simple_bundle") %>% 
  pipe_label_links(field="source_id",fun = "count") %>% 
  pipe_label_factors(field="source_count",add_field_name = T) %>% 
  pipe_wrap_factors() %>% 
    make_print_map 

Label links

oo %>%
    pipe_select_factors(5) %>%
    pipe_bundle_links(("#Name of village")   ) %>%
    pipe_label_links(field = "#Name of village",fun="unique") %>%
    make_interactive_map


oo %>%
    pipe_select_factors(5) %>%
    pipe_bundle_links(("vill")   ) %>%
    pipe_label_links(field = "#Name of village",fun="unique") %>%
    make_interactive_map





e3 %>%
  pipe_label_links("link_id",fun = "literal") %>%
  pipe_label_links("from_label",fun = "literal",add_field_name = T,clear_previous = F) %>%
  make_interactive_map

e3 %>%
  pipe_bundle_links() %>% 
  pipe_label_links("link_id",fun = "literal",add_field_name = T) %>%
  make_interactive_map

e3 %>%
  pipe_bundle_links() %>% 
  pipe_label_links("link_id",fun = "literal") %>%
  pipe_label_links("from_label",fun = "literal",clear_previous = F) %>%
  make_interactive_map

e3 %>%
  pipe_bundle_links() %>% 
  parse_commands("label links field=statement_id fun=unique clear_previous=F") %>%
  make_interactive_map

Bundling links

Note the defaults for bundle_links and label_links:

oo %>%
    pipe_select_factors(5) %>%
    pipe_bundle_links(("#Name of province")   ) %>%
    pipe_label_links(("#Name of province")   ) %>%
    make_interactive_map

oo %>%
    parse_commands("
    select links top=15
select factors top=10
bundle links field=#2
label factors field=frequency add_field_name=FALSE clear_previous=FALSE
scale links value=count: link_id
label links field=#2Name of village fun=unique add_field_name=FALSE clear_previous=TRUE
color text field=is_opposable lo=black hi=#f26d04") %>%
    make_interactive_map
oo %>%
    pipe_select_factors(5) %>%
    pipe_bundle_links("village"   ) %>%
    pipe_label_links("village" ,fun = "unique"  ) %>%
    make_interactive_map
ll %>%
    pipe_find_factors(value="economic") %>%
    pipe_select_factors(5) %>%
    pipe_bundle_links() %>%
    pipe_label_links() %>%
    make_interactive_map
ll %>%
    pipe_find_factors(value="economic") %>%
    pipe_select_factors(5) %>%
    pipe_bundle_links() %>%
    pipe_label_links() %>%
    make_interactive_map

Note the default for bundle_links is equivalent to simple_bundle:

ll %>%
    pipe_find_factors(value="economic") %>%
    pipe_select_factors(5) %>%
    pipe_bundle_links(group="simple_bundle") %>%
    pipe_label_links() %>%
    make_interactive_map

Group and label by sex and scale by count:

ll %>%
    pipe_select_factors(5) %>%
    pipe_bundle_links(field="1. Sex") %>%
    pipe_scale_links("link_id",fun = "count") %>%
    pipe_label_links("1. Sex",fun = "unique") %>%
    pipe_color_links("1. Sex",fun = "unique") %>%
    make_interactive_map
ll %>%
    pipe_select_links(16) %>%
    pipe_bundle_links(field="1. Sex") %>%
    pipe_label_links("link_id",fun = "count") %>%
    make_interactive_map

Group by sex and scale and colour by count:

ll %>%
    pipe_select_factors(5) %>%
    pipe_bundle_links(field="1. Sex") %>%
    pipe_color_links("link_id",fun = "count") %>%
    pipe_scale_links("link_id",fun = "count") %>%
    pipe_label_links("link_id",fun = "count") %>%
    make_interactive_map

Proportion

ll %>%    
  pipe_find_factors(value="sed yield") %>%
  pipe_bundle_links(field="District") %>% 
  pipe_color_links(field="District",fun="unique") %>% 
  pipe_label_links(value="percent: link_id") %>%  
  pipe_scale_links(field="link_id",fun="count") %>%  
  make_print_map
ll %>%    
  pipe_find_factors(value="sed yield") %>%
  pipe_bundle_links(field="1. Sex") %>% 
  pipe_color_links(field="1. Sex",fun="unique") %>% 
  pipe_label_links(field="link_id",fun="percent") %>%  
  pipe_scale_links(field="link_id",fun="count") %>%  
  make_print_map
ll %>%    
  pipe_find_factors(value="sed yield") %>%
  pipe_bundle_links(field="1. Sex") %>% 
  pipe_color_links(field="1. Sex",fun="unique") %>% 
  pipe_label_links(field="source_id",fun="percent") %>%  
  pipe_scale_links(field="source_id",fun="percent") %>%  
  make_print_map
ll %>%    
  pipe_find_factors(value="sed yield",down=0) %>%
  pipe_bundle_links(field="1. Sex") %>% 
  pipe_color_links(field="source_id",fun="percent") %>% 
  pipe_label_links(field="source_id",fun="percent") %>%  
  pipe_scale_links(field="source_id",fun="count") %>%  
  make_print_map

Surprise

ll %>%    
  pipe_find_factors(value="sed yield",down=0) %>%
  pipe_bundle_links(field="1. Sex") %>% 
  pipe_color_links(field="1. Sex",fun="unique") %>% 
  pipe_label_links(field="source_id",fun="surprise") %>%  
  pipe_scale_links(field="source_id",fun="count") %>%  
  make_print_map
ll %>%    
  pipe_find_factors(value="sed yield",down=0) %>%
  pipe_bundle_links(field="1. Sex") %>% 
  pipe_label_links(field="1. Sex",fun="unique") %>% 
  pipe_color_links(field="source_id",fun="surprise") %>%  
  pipe_scale_links(field="source_id",fun="count") %>%  
  make_print_map

Using initials to shorten the labels

oo %>%    
  pipe_find_factors(value="crops",down=0) %>%
  pipe_bundle_links(field="#4Sex of the respondent") %>% 
  pipe_label_links(field="#4Sex of the respondent",fun="initials") %>% 
  pipe_color_links(field="source_id",fun="surprise") %>%  
  pipe_scale_links(field="source_id",fun="count") %>%  
  make_print_map
oh %>%    
  pipe_select_factors(10) %>%
  pipe_bundle_links(field="simple_bundle") %>% 
  pipe_label_links(field="from_label",fun="initials") %>% 
  make_print_map

Recalculating

Shouldn't make any difference as factor and link fields are now recalculated after every transform; but beforeids and afterids are added only on load_mapfile.

ll %>% 
  pipe_find_factors(value="WASH") %>% 
  pipe_color_factors(field="betweenness") %>% 
  make_interactive_map

ll %>% 
  pipe_find_factors(value="WASH") %>% 
  pipe_recalculate_factors() %>% 
  pipe_color_factors(field="betweenness") %>% 
  make_interactive_map

Mark links

so %>% 
  pipe_label_links(field = "source_id",fun="literal") %>% 
  pipe_mark_links(field="source_id") %>% 
  make_print_map

e3 %>% 
  pipe_label_links(field = "source_id",fun="literal") %>% 
  pipe_mark_links(field="source_id") %>% 
  make_print_map

ee %>% 
  pipe_label_links(field = "source_id",fun="literal") %>% 
  pipe_mark_links(field="source_id") %>% 
  make_print_map


so %>% 
  pipe_bundle_links(field = "source_id") %>% 
  pipe_label_links(field = "source_id",fun="literal") %>% 
  pipe_mark_links(field="source_id") %>% 
  make_print_map

so %>% 
  pipe_combine_opposites() %>% 
  pipe_bundle_links(field = "flipped_bundle") %>% 
  pipe_label_links(field = "source_id",fun="literal") %>% 
  pipe_mark_links(field="source_id") %>% 
  make_print_map

ll %>% 
  pipe_select_factors(5) %>% 
  pipe_bundle_links(field = "simple_bundle") %>% 
  pipe_mark_links(field="source_id") %>% 
  make_print_map

Show continuity

#original:

so %>% 
  pipe_label_links(field = "source_id",fun="unique") %>% 
  make_print_map

so %>% 
  pipe_label_links(field = "source_id",fun="unique") %>% 
  pipe_show_continuity(field="source_id",type="label") %>% 
  make_print_map
so %>% 
  pipe_label_links(field = "source_id",fun="unique") %>% 
  pipe_show_continuity(field="source_id") %>% 
  make_print_map


ee %>% 
  pipe_label_links(field = "source_id",fun="unique") %>% 
  pipe_show_continuity(field="source_id") %>% 
  make_print_map

e3 %>% 
  pipe_label_links(field = "source_id",fun="unique") %>% 
  pipe_show_continuity(field="source_id") %>% 
  make_print_map

e3 %>% 
  pipe_zoom_factors() %>% 
  pipe_show_continuity(field="source_id") %>% 
  pipe_label_links(field = "source_id",fun="unique") %>% 
  make_print_map

e3 %>% 
  pipe_bundle_factors("Flooding") %>% 
  pipe_show_continuity(field="source_id") %>% 
  pipe_label_links(field = "source_id",fun="unique") %>% 
  make_print_map

e3 %>% 
  pipe_bundle_factors("Flooding") %>% 
  pipe_bundle_links(field = "source_id") %>% 
  pipe_label_links(field = "source_id",fun="literal") %>% 
  pipe_show_continuity(field="source_id") %>% 
  make_print_map



so %>% 
  pipe_bundle_links() %>% 
  pipe_label_links(field = "source_id",fun="unique") %>% 
  pipe_show_continuity(field="source_id") %>% 
  make_print_map



so %>% 
  pipe_combine_opposites() %>% 
  pipe_label_links("link_id","literal") %>% 
  pipe_show_continuity(field="source_id") %>% 
  make_print_map

so %>% 
  pipe_combine_opposites() %>% 
  pipe_show_continuity() %>% 
  make_print_map

so %>% 
  pipe_combine_opposites() %>% 
  pipe_bundle_links(field = "flipped_bundle") %>% 
  pipe_show_continuity(field="source_id") %>% 
  pipe_label_links(field = "source_id",fun="unique") %>% 
  make_print_map




# Order should not matter, but you can't put bundle links later


so %>% 
  pipe_combine_opposites() %>% 
  pipe_show_continuity(field="source_id") %>% 
  pipe_bundle_links(field = "flipped_bundle") %>% 
  pipe_label_links(field = "source_id",fun="unique") %>% 
  make_print_map
ll %>% 
  pipe_select_factors(5) %>% 
  pipe_bundle_links(field = "simple_bundle") %>% 
  pipe_scale_links(field = "link_id",fun="count") %>% 
  pipe_show_continuity(field="source_id") %>% 
  make_print_map


hz %>%
  pipe_show_continuity(field="source_id") %>% 
    make_print_map 

hz %>%
  pipe_zoom_factors(1) %>%
  pipe_show_continuity(field="source_id") %>% 
    make_print_map 

Group and label by sex and scale by count:

ll %>%
    pipe_select_factors(5) %>%
    pipe_bundle_links(field="1. Sex") %>%
    pipe_scale_links("link_id",fun = "count") %>%
    pipe_label_links("1. Sex",fun = "unique") %>%
    pipe_color_links("1. Sex",fun = "unique") %>%
    pipe_show_continuity(field="source_id") %>% 
    make_print_map

ll %>%
    pipe_select_factors(5) %>%
    pipe_find_links(field = "statement_id",value=90,operator="greater") %>%
    pipe_find_links(field = "statement_id",value=290,operator="less") %>%
    pipe_bundle_links(field="1. Sex") %>%
    pipe_scale_links("link_id",fun = "count") %>%
    pipe_label_links("source_id",fun = "unique") %>%
    pipe_color_links("1. Sex",fun = "unique") %>%
    pipe_show_continuity(field="source_id") %>% 
    make_print_map

Nested maps

tt %>%
    pipe_zoom_factors(1) %>%
    pipe_select_factors(5) %>%
    make_interactive_map
tt %>%
    pipe_zoom_factors(1) %>%
    pipe_bundle_links() %>%
    pipe_label_links() %>%
    pipe_scale_links() %>%
    make_print_map

Zooming out and showing source count / frequency

sz %>%
    pipe_zoom_factors(1) %>%
  pipe_bundle_links(field="simple_bundle") %>% 
  pipe_label_links(field="source_id",fun = "count") %>% 
  pipe_label_factors(field="frequency",add_field_name = F) %>% 
  pipe_wrap_factors() %>% 
    make_print_map 
sz %>%
  pipe_zoom_factors(1,preserve_frequency = 4,frequency_field = "frequency",frequency_other = "(other)") %>%
  pipe_bundle_links(field="simple_bundle") %>% 
  pipe_label_factors(field="frequency",add_field_name = F) %>% 
  pipe_wrap_factors() %>% 
    make_print_map 
oig %>%
    pipe_zoom_factors(1,preserve_frequency = 20,frequency_field = "source_count") %>%
  pipe_bundle_links(field="simple_bundle") %>% 
  pipe_label_links(field="source_id",fun = "count") %>% 
  pipe_label_factors(field="source_count",add_field_name = F) %>% 
  pipe_color_borders(field="frequency_preserved",lo="white") %>% 
  pipe_wrap_factors() %>% 
    make_print_map 
tt %>%
    pipe_zoom_factors(1,preserve_frequency = 80) %>%
  pipe_bundle_links(field="simple_bundle") %>% 
  pipe_label_links(field="link_id",fun = "count") %>% 
  pipe_label_factors(field="frequency",add_field_name = F) %>% 
  pipe_color_borders(field="frequency_preserved",lo="white") %>% 
  pipe_wrap_factors() %>% 
    make_print_map 

cc %>%
  pipe_find_factors(value="Improved health") %>% 
    pipe_zoom_factors(1) %>%
  pipe_select_factors(top=10) %>% 
  pipe_bundle_links(field="simple_bundle") %>% 
  pipe_label_links(field="source_id",fun = "count") %>% 
  pipe_label_factors(field="source_count",add_field_name = F) %>% 
  pipe_label_factors(field="frequency",add_field_name = F) %>% 
  pipe_wrap_factors() %>% 
    make_print_map 

cc %>%
  pipe_find_factors(value="Improved health") %>% 
  pipe_zoom_factors(1) %>%
  pipe_select_factors(top=10) %>% 
  pipe_bundle_links(field="simple_bundle") %>% 
  pipe_label_links(field="source_id",fun = "count") %>% 
  pipe_label_factors(field="source_count",add_field_name = F) %>% 
  pipe_label_factors(field="frequency",add_field_name = F) %>% 
  pipe_wrap_factors() %>% 
    make_print_map 

oi %>% 
  pipe_find_factors(value="Take a loan") %>%
  pipe_zoom_factors(1,preserve_frequency = 2,frequency_other = "(other)") %>%
  # pipe_label_factors("source_count") %>% 
  # pipe_label_links(value="unique:source_id") %>% 
  make_print_map

Combining opposites

hh %>% 
  make_print_map()
hh %>% 
  pipe_combine_opposites %>% 
  pipe_label_links(value="count:link_id") %>% 
  make_print_map()

# artificial arrowlabels
hh %>% 
    pipe_combine_opposites %>% pipe_update_mapfile(.,links=.$links %>% mutate(color="limegreen",taillabel=c("","","\u274C","\u274C","","\u274C"),headlabel=c("","","\u274C","\u274C","\u274C","\u274C")))  %>% make_print_map()

hh %>% 
    pipe_combine_opposites %>% pipe_update_mapfile(.,links=.$links %>% mutate(color="limegreen",taillabel=c("+","+","~","~","+","~"),headlabel=c("+","+","~","~","~","~")))  %>% make_print_map()

hh %>% 
    pipe_combine_opposites %>% pipe_update_mapfile(.,links=.$links %>% mutate(color="limegreen",arrowtail=c("","","nonetee","nonetee","","nonetee"),arrowhead=c("nonetee","","veenonenonetee","veenonenonetee","veenonenonetee","veenonenonetee")))  %>% make_print_map()

Nested maps with opposites

Note colours in Interactive view

tt %>%
    pipe_zoom_factors(1) %>%
    pipe_combine_opposites() %>%
    pipe_select_links(3) %>%
    make_print_map


tt %>%
    pipe_zoom_factors(1) %>%
    pipe_select_links(15) %>%
    pipe_combine_opposites() %>%
  pipe_bundle_links("flipped_bundle") %>% 
  pipe_label_links(value="count:link_id") %>% 
    make_print_map


tt %>%
    pipe_zoom_factors(1) %>%
    pipe_combine_opposites() %>%
    pipe_select_links(3) %>%
    make_interactive_map

Factor quick fields

# factors <- de$factors

de %>% 
  pipe_color_text(field="time") %>% 
  make_print_map

Hiding quickfields

de %>% 
  pipe_hide_quickfields %>% 
  make_print_map


de %>% 
  pipe_color_borders(field="happiness") %>% 
  pipe_label_factors(field = "time") %>% 
  pipe_hide_quickfields %>% 
  make_print_map

equivalent:

de %>% 
  pipe_find_factors(field="time",value="after",up=0,down=0) %>% 
  make_print_map

de %>% 
  pipe_find_factors(field="label",value="time:after",up=0,down=0) %>% 
  make_print_map

zoom

de %>% 
  pipe_zoom_factors(1) %>% 
  pipe_color_factors(field="time") %>% 
  make_print_map

Link quick fields

# factors <- de$factors

de %>% 
  pipe_recalculate_all() %>% 
  pipe_color_links(field="plausibility") %>% 
  make_print_map


de %>% 
  pipe_color_text(field="happiness") %>% 
  pipe_hide_quickfields %>% 
  make_print_map


de %>% 
  pipe_label_factors(field = "time") %>% 
  pipe_hide_quickfields %>% 
  make_print_map

Path tracing

cat("### Single\n")  

ll %>% 
  pipe_trace_paths(from = "main_drivers",to="main_outcomes",length = 3) %>% 
  pipe_select_factors(15) %>% 
  make_interactive_map

ma %>%    
  pipe_trace_paths(from = "Shared roles",to="balanced",length = 1) %>% 
  pipe_select_factors(15) %>% 
  make_interactive_map
ma %>%    
  pipe_trace_paths(from = "Covid-19",to="Business",length = 2) %>% 
  pipe_select_factors(15) %>% 
  make_interactive_map

oo %>%    
  pipe_select_factors(15) %>% 
  pipe_trace_paths(from = "Learnt about farming",to="",length = 5) %>% 
  make_interactive_map

ee %>%    
  pipe_trace_paths(from = "Funds",to="area",length = 5) %>% 
  make_interactive_map

cat("### Case insensitive\n")  

ee %>%    
  pipe_trace_paths(from = "funds",to="aREa",length = 5) %>% 
  make_interactive_map

cat("### Failing; no paths at all\n")  

ee %>%    
  pipe_trace_paths(from = "xx",to="yy",length = 5) %>% 
  make_interactive_map

cat("### Failing; no paths\n")  
ee %>%    
  pipe_trace_paths(from = "Funds",to="yy",length = 5) %>% 
  make_interactive_map

ee %>%    
  pipe_trace_paths(from = "xx",to="Property",length = 5) %>% 
  make_interactive_map

cat("### Implicit multiple\n")  

ee %>%    
  pipe_trace_paths(from = "High",to="Damage",length = 5) %>% 
  make_interactive_map

cat("### Explicit multiple\n")  

ee %>%    
  pipe_trace_paths(from = "High",to="Property | Business",length = 5) %>% 
  make_interactive_map

ee %>%    
  pipe_trace_paths(from = "High",to="Property OR Business",length = 5) %>% 
  make_interactive_map

cat("Should this be possible?")

ee %>%    
  pipe_trace_paths(from = "High",to="Property OR Business",length = 5) %>% 
  make_interactive_map

tt %>%
  pipe_trace_paths(from = "Capabilities",to="[OP3]",length = 2) %>% 
  make_interactive_map

ee %>%    
  pipe_trace_paths(from = "Funds",to="area",length = 5) %>% 
  make_print_map()

Robustness

## request is large but ok
pa %>%    
  pipe_trace_paths(from = "",to="~Impact on wellbeing",length = 1) %>% 
  make_print_map()
pa %>%    
  pipe_trace_paths(from = "Covid",to="",length = 3) %>% 
  make_print_map()

## request is large

if(F){e3 %>%    
  pipe_trace_robustness(from = "High",to="Damage",length = 5) %>% 
  make_print_map()

ee %>%    
  pipe_trace_robustness(from = "High",to="Damage",length = 5) %>% 
  get_robustness()

tt %>%
  pipe_trace_robustness(from = "Capabilities",to="[OP3]",length = 2) %>% 
  pipe_wrap_factors() %>% 
  make_print_map()

tt %>%
  pipe_trace_robustness(from = "Capabilities",to="[OP3",length = 2) %>% 
  pipe_wrap_factors() %>% 
  make_print_map()

## checking the robustness gets transferred
tt %>%
  pipe_trace_robustness(from = "Capabilities",to="[OP3]",length = 2) %>% 
  pipe_wrap_factors() %>%
  pipe_wrap_links() %>%
  pipe_select_links(10) %>%
  get_robustness()

tt %>%
  pipe_trace_robustness(from = "Capabilities",to="[OP3",length = 2) %>% 
  get_robustness()

tt %>%
  pipe_trace_robustness(from = "Capabilities; [P13",to="[OP3]",length = 2) %>% 
  get_robustness()

e3  %>%
  pipe_trace_robustness(from = "High",to="People moving",length = 5) %>% 
  make_print_map()

e3  %>%
  pipe_trace_robustness(from = "High",to="",length = 5) %>% 
  make_print_map()

e3  %>%
  pipe_trace_robustness(from = "High",to="People moving",length = 5) %>% 
  get_robustness() %>% 
  kable
e3  %>%
  pipe_trace_robustness(from = "High",to="Flooding",length = 5) %>% 
  get_robustness() %>% 
  kable
e3  %>%
  pipe_trace_robustness(from = "High",to="Damage",length = 5) %>% 
  get_robustness() %>% 
  kable
e3  %>%
  pipe_trace_robustness(from = "External",to="Damage",length = 5) %>% 
  get_robustness() %>% 
  kable
e3  %>%
  pipe_trace_robustness(from = "External",to="Outcome",length = 5) %>% 
  get_robustness()%>% 
  kable

}

Robustness by field

Just one source:

ee  %>%
  pipe_trace_robustness(from = "Funds",to="Increased",length = 5,field = "source_id") %>% get_robustness

ll  %>%
  pipe_trace_robustness(from = "Cash",to="Income",length = 5,field="source_id") %>% 
  get_robustness()

Check that opposites colouring is always preserved?

if(F){
hh  %>%
  pipe_trace_robustness(from = "Revision",to="happy",length = 5) %>% 
  pipe_combine_opposites %>% 
  make_print_map()

hh  %>%
  pipe_combine_opposites %>% 
  pipe_find_factors(value="exam") %>% 
  make_print_map()

hh  %>%
  pipe_combine_opposites %>% 
  pipe_zoom_factors() %>% 
  pipe_find_factors(value="exam") %>% 
  pipe_select_factors(2) %>% 
  pipe_select_links(3) %>% 
  make_print_map()
}

Colours in interactive map

hh  %>%
  pipe_combine_opposites %>% 
  pipe_zoom_factors() %>% 
  make_interactive_map()

Trace threads

e3  %>%
  pipe_trace_paths(from = "rainfall",to="",length = 4) %>% 
  pipe_trace_threads() %>% 
  pipe_bundle_links() %>% 
  pipe_label_links(field = "has_downstream_threads",fun = "sum") %>% 
  pipe_label_links(field = "source_id",fun = "literal",clear_previous = F) %>% 
  pipe_color_links(field = "has_downstream_threads",fun = "sum") %>% 
  pipe_color_borders(field="n_downstream_threads_surviving") %>% 
  make_print_map() 

e3  %>%
  pipe_trace_paths(from = "rainfall",to="",length = 4) %>% 
  pipe_trace_threads() %>% 
  pipe_bundle_links() %>% 
  pipe_label_links(field = "downstream_threads",fun = "literal") %>% 
  pipe_color_links(field = "has_downstream_threads",fun = "sum") %>% 
  pipe_color_borders(field="n_downstream_threads_surviving") %>% 
  make_print_map() 

e3  %>%
  pipe_trace_paths(from = "rainfall",to="",length = 4) %>% 
  pipe_trace_threads() %>% 
  pipe_bundle_links() %>% 
  pipe_label_links(field = "downstream_threads",fun = "count") %>% 
  pipe_color_links(field = "has_downstream_threads",fun = "sum") %>% 
  pipe_color_borders(field="n_downstream_threads_surviving") %>% 
  make_print_map() 

# with multiple origins
e3  %>%
  pipe_trace_paths(from = "External",to="",length = 2) %>% 
  pipe_trace_threads() %>% 
  pipe_bundle_links() %>% 
  pipe_label_links(field = "has_downstream_threads",fun = "sum") %>% 
  pipe_color_links(field = "has_downstream_threads",fun = "sum") %>% 
  pipe_color_factors(field="found_type") %>% 
  pipe_color_borders(field="n_downstream_threads_surviving") %>% 
  make_print_map() 

ll  %>%
  pipe_trace_paths(from = "OrgX",to="Income",length = 4) %>% 
  pipe_trace_threads() %>% 
  pipe_bundle_links() %>% 
  pipe_label_links(field = "has_downstream_threads",fun = "sum") %>% 
  pipe_color_links(field = "has_downstream_threads",fun = "sum") %>% 
  make_print_map() 

# works also with other fields
ll  %>%
  pipe_trace_paths(from = "OrgX",to="Income",length = 4) %>% 
  pipe_trace_threads(field="r.2. Village") %>% 
  # pipe_bundle_links(field="r.2. Village") %>% 
  pipe_label_links(field = "downstream_threads",fun = "unique") %>% 
  pipe_color_links(field = "has_downstream_threads",fun = "sum") %>% 
  make_print_map() 

# with no target
ll  %>%
  pipe_trace_paths(from = "OrgX",to="",length = 2) %>% 
  pipe_trace_threads() %>% 
  pipe_bundle_links() %>% 
  pipe_label_links(field = "has_downstream_threads",fun = "sum") %>% 
  pipe_color_links(field = "has_downstream_threads",fun = "sum") %>% 
  make_print_map() 

ll  %>%
  pipe_trace_paths(from = "doesnotexist",to="Income",length = 4) %>% 
  pipe_trace_threads() %>% 
  pipe_bundle_links() %>% 
  pipe_label_links(field = "has_downstream_threads",fun = "sum") %>% 
  pipe_color_links(field = "has_downstream_threads",fun = "sum") %>% 
  make_print_map() 

ll  %>%
  pipe_trace_paths(from = "OrgX",to="doesnotexist",length = 4) %>% 
  pipe_trace_threads() %>% 
  pipe_bundle_links() %>% 
  pipe_label_links(field = "has_downstream_threads",fun = "sum") %>% 
  pipe_color_links(field = "has_downstream_threads",fun = "sum") %>% 
  make_print_map() 


oo %>%    
  pipe_select_factors(15) %>% 
  pipe_trace_paths(from = "Learnt about farming",to="",length = 5) %>% 
  pipe_trace_threads() %>% 
  pipe_bundle_links() %>% 
  pipe_label_links(field = "has_downstream_threads",fun = "sum") %>% 
  pipe_color_links(field = "has_downstream_threads",fun = "sum") %>% 
  make_print_map

oo %>%    
  pipe_select_factors(10) %>% 
  pipe_trace_paths(from = "Learnt about farming",to="Health",length = 3) %>% 
  pipe_trace_threads() %>% 
  pipe_bundle_links() %>% 
  pipe_label_links(field = "has_downstream_threads",fun = "sum") %>% 
  pipe_label_links(field = "source_id",fun = "count",clear_previous = F) %>% 
  pipe_color_links(field = "has_downstream_threads",fun = "sum") %>% 
  pipe_color_factors(field="found_type") %>% 
  make_print_map

# note that sum of has_downstream_threads can be more than number of unique sources
oo %>%    
  pipe_select_factors(10) %>% 
  pipe_trace_paths(from = "Learnt about farming",to="Health",length = 3) %>% 
  pipe_trace_threads() %>% 
  pipe_bundle_links() %>% 
  # pipe_label_links(field = "has_downstream_threads",fun = "sum") %>% 
  # pipe_label_links(field = "continuation_id",fun = "count",clear_previous = F) %>% 
  pipe_label_links(field = "downstream_threads",fun = "unique",clear_previous = F) %>%
  pipe_color_links(field = "has_downstream_threads",fun = "sum") %>% 
  pipe_color_factors(field="found_type") %>% 
  pipe_wrap_links() %>% 
  make_print_map


oi %>%    
  # pipe_select_factors(20) %>% 
  pipe_trace_paths(from = "Take a loan",to="",length = 4) %>% 
  pipe_trace_threads() %>% 
  pipe_bundle_links() %>% 
  pipe_label_links(field = "has_downstream_threads",fun = "sum") %>% 
  pipe_label_links(field = "source_id",fun = "count",clear_previous = F) %>% 
  pipe_color_links(field = "has_downstream_threads",fun = "sum") %>% 
  pipe_color_factors(field="found_type") %>% 
  make_print_map
oi %>%    
  # pipe_select_factors(20) %>% 
  pipe_trace_paths(from = "Need more",to="",length = 2) %>% 
  pipe_trace_threads() %>% 
  pipe_bundle_links() %>% 
  pipe_label_links(field = "has_downstream_threads",fun = "sum") %>% 
  pipe_label_links(field = "source_id",fun = "count",clear_previous = F) %>% 
  pipe_label_links(field = "source_id",fun = "literal",clear_previous = F) %>% 
  pipe_color_links(field = "has_downstream_threads",fun = "sum") %>% 
  pipe_color_factors(field="found_type") %>% 
  make_print_map

# kb <- load_mapfile("kenya-beka")
# 
# kb %>%    
#   pipe_trace_paths(from = "Covid-19",to="~Performance",length = 3) %>% 
#   pipe_trace_threads() %>% 
#   pipe_bundle_links() %>% 
#   pipe_label_links(field = "downstream_threads",fun = "initials") %>% 
#   make_print_map

upstream

e3  %>%
  pipe_trace_paths(from = "",to="Outcome",length = 4) %>% 
  pipe_trace_threads(direction="up") %>% 
  pipe_bundle_links() %>% 
  pipe_label_links(field = "source_id",fun = "literal") %>% 
  pipe_label_links(field = "has_upstream_threads",fun = "sum",clear_previous = F) %>% 
  pipe_color_links(field = "has_upstream_threads",fun = "sum") %>% 
  pipe_color_borders(field="n_upstream_threads_surviving") %>% 
  pipe_label_factors(field="n_upstream_threads_surviving") %>% 
  make_print_map() 

oi %>%    
  pipe_trace_paths(from = "Flee",to="",length = 3) %>% 
  pipe_trace_threads(direction="down") %>% 
  pipe_bundle_links() %>% 
  pipe_label_links(field = "has_downstream_threads",fun = "sum") %>% 
  pipe_label_links(field = "source_id",fun = "literal",clear_previous = F) %>% 
  pipe_color_links(field = "has_downstream_threads",fun = "sum") %>% 
  pipe_color_factors(field="found_type") %>% 
  make_print_map

oi %>%    
  pipe_trace_paths(from = "",to="Financial diary",length = 2) %>% 
  pipe_trace_threads(direction="up") %>% 
  pipe_bundle_links() %>% 
  pipe_label_links(field = "has_upstream_threads",fun = "sum") %>% 
  pipe_label_links(field = "source_id",fun = "literal",clear_previous = F) %>% 
  pipe_color_links(field = "has_upstream_threads",fun = "sum") %>% 
  pipe_color_factors(field="found_type") %>% 
  make_print_map
if(F){
graf <- tt1
graf$factors %>% filter(factor_id %notin% graf$links$from & factor_id %notin% graf$links$to)  %>% nrow

graf$links %>% filter(from %notin% graf$factors$factor_id & to %notin% graf$factors$factor_id)  %>% nrow

graf$links %>% filter(statement_id %notin% graf$statements$statement_id) %>% nrow
  }

Cluster factors

ee %>% 
  pipe_coerce_mapfile %>% 
  pipe_cluster_factors("Damage OR Flood") %>% 
  make_print_map

Pipe-able:

ee %>% 
  pipe_cluster_factors("Damage OR Flood") %>% 
  pipe_cluster_factors("Rising") %>% 
  make_print_map

Large map

cm <- 
  load_mapfile("cmi-gender")
library("tictoc")
tic()
make_interactive_map(cm)
toc()

Data manipulation, file management etc

Accessing the data

One column in one table

ll %>%
    pipe_find_factors(value="economic") %>%
    .$factors %>%
    .$label %>% 
  knitr::kable()

Merging two maps

if(T)merge_mapfile(ee,tt %>% pipe_select_factors(top=8)) %>% 
  pipe_color_factors(field="map_id") %>% 
  pipe_color_links(field="map_id",fun="unique") %>% 
  make_interactive_map

Note warning if factor labels are shared

if(T)load_mapfile("example2") %>%
  pipe_coerce_mapfile %>% 
  pipe_merge_mapfile("example2") %>% 
  pipe_color_factors(field="map_id") %>% 
  pipe_color_links(field="map_id",fun="unique") %>% 
  make_interactive_map

Editing maps directly

There is no guarantee that the resulting map is still a standard mapfile.

ee$factors$label[1] <- "Label changed"
ee %>% make_interactive_map

Editing maps with pipe_update_mapfile

There is no guarantee that the resulting map is still a standard mapfile.

ee %>% 
  pipe_update_mapfile(factors = ee$factors %>% mutate(label="one")) %>% 
  make_interactive_map

Printing the filters

# example2 %>% 
#   pipe_coerce_mapfile %>% 
#   pipe_find_links(field = "link_id",value=1)  %>% 
#   pipe_select_factors(20) %>%  
#   pipe_remove_isolated() %>% 
#   pipe_select_links(20) %>%  
#   pipe_zoom_factors() %>% 
#   pipe_find_statements(field = "text",value="Flo") %>% 
#   pipe_find_factors(value="Flo") %>%
#   pipe_remove_brackets("[") %>% 
#   pipe_trace_robustness(from = "Flood",to="Damage") %>% 
#   pipe_trace_paths(from = "Flood",to="Damage") %>% 
#   pipe_combine_opposites() %>% 
#   pipe_bundle_links() %>% 
#   pipe_label_links() %>% 
#   attr("info") %>% 
#   str
# 
# example2 %>%
#   pipe_coerce_mapfile() %>%
#   pipe_bundle_links() %>%
#   pipe_scale_links() %>%
#   pipe_label_links() %>%
#   pipe_color_links() %>%
#   pipe_scale_factors(field = "frequency") %>%
#   pipe_label_factors() %>%
#   pipe_color_factors() %>%
#   pipe_color_borders() %>%
#   pipe_mark_links() %>%
#   pipe_show_continuity() %>%
#   pipe_cluster_factors() %>%
#   pipe_wrap_factors() %>%
#   pipe_wrap_links() %>%
#   print_filter()

You can also load up an Excel file:

# system.file("extdata", "quip-lorem", package = "CausalMapFunctions") %>% 
#   get_mapfile_from_excel()


stevepowell99/CausalMapFunctions documentation built on Oct. 12, 2023, 11:13 a.m.