Loading example datasets

(After loading CausalMapFunctions library)

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

  • example2
  • quip_example

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

Visualise the files like this:

The file 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.

Basic examples

Interactive and Print maps

label links field=link_id fun=unique
label links field=link_id fun=unique

Selecting and finding

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

  • also the links are filtered (removing links to removed factors)
  • the statements are not touched

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

  • the factors are not filtered (but using a different command you can remove any factors which no longer have any links)
  • the statements are not touched

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

  • also the links are filtered (removing links to removed statements)
  • the factors are filtered
select factors top=15

Simple frequency

find links field=simple_frequency value=50 operator=greater
select links top=5
find statements field=statement_id value=5 operator=equals
find factors value=economic

Zero up and down

find factors value=rainfall up=0 down=0 remove_isolated=T
find factors value=rainfall up=0 down=0 remove_isolated=F

Case insensitive

find factors value=business|property

Should these work?

find factors value=business|property
find factors value=business OR property

notcontains

find factors value=sea operator=notcontains
find factors value=c("sea", "High") operator=notcontains
find statements field=statement_id value=1 operator=notcontains
find statements field=statement_id value=1 operator=notcontains

notequals

find statements field=statement_id value=1 operator=notequals
find factors value=c("Coastal erosion") operator=notequals

Does work:

find factors value=c("business", "property")

Order matters

find factors value=economic
select factors top=5

No result

find factors value=asdfasdfasdf
find links field=from_label value=economic operator=contains

Numerical comparison

find statements field=statement_id value=20 operator=less

No result

find statements field=statement_id value=2e+07 operator=greater

Highlight only

find factors value=Damage highlight_only=T
color factors field=found

Note this doe sn’twork in the app:

find links field=from_label value=Damage highlight_only=T
color links field=found fun=literal

Conditional formatting

select factors top=5
scale factors field=frequency
select factors top=5
scale factors field=frequency
select factors top=5
color factors field=frequency
color borders field=betweenness
wrap factors length=5
select factors top=5
color links value=count: link_id
wrap factors length=5
label links field=from_label fun=unique
wrap links length=6
label links value=unique: from_label
wrap links length=6

Remove brackets

select factors top=5
remove brackets

Bundle factors

bundle factors value=IEA
select factors top=5

Show continuity

label links field=source_id fun=unique
label links field=source_id fun=unique
show continuity field=source_id type=label
label links field=source_id fun=unique
show continuity field=source_id
label links field=source_id fun=unique
show continuity field=source_id
label links field=source_id fun=unique
show continuity field=source_id
zoom factors
show continuity field=source_id
label links field=source_id fun=unique
bundle factors value=Flooding
show continuity field=source_id
label links field=source_id fun=unique
bundle factors value=Flooding
bundle links field=source_id
label links field=source_id fun=literal
show continuity field=source_id
bundle links
label links field=source_id fun=unique
show continuity field=source_id
combine opposites
label links field=link_id fun=literal
show continuity field=source_id
combine opposites
show continuity
combine opposites
bundle links field=flipped_bundle
show continuity field=source_id
label links field=source_id fun=unique
combine opposites
show continuity field=source_id
bundle links field=flipped_bundle
label links field=source_id fun=unique
select factors top=5
bundle links field=simple_bundle
scale links field=link_id fun=count
show continuity field=source_id
show continuity field=source_id
zoom factors level=1
show continuity field=source_id

Group and label by sex and scale by count:

## Warning in as_numeric_if_all(vec): NAs introduced by coercion
select factors top=5
bundle links field=1. Sex
scale links field=link_id fun=count
label links field=1. Sex fun=unique
color links field=1. Sex fun=unique
show continuity field=source_id
## Warning in as_numeric_if_all(vec): NAs introduced by coercion
select factors top=5
find links field=statement_id value=90 operator=greater
find links field=statement_id value=290 operator=less
bundle links field=1. Sex
scale links field=link_id fun=count
label links field=source_id fun=unique
color links field=1. Sex fun=unique
show continuity field=source_id

Nested maps

zoom factors level=1
select factors top=5
zoom factors level=1
bundle links
label links
scale links

Zooming out and showing source count

zoom factors level=1
bundle links field=simple_bundle
label links field=source_id fun=count
wrap factors

Combining opposites

combine opposites

Nested maps with opposites

Note colours in Interactive view

zoom factors level=1
combine opposites
select links top=3
zoom factors level=1
combine opposites
select links top=3

Path tracing

## ### Single
trace paths from=Funds to=area length=5
## ### Case insensitive
trace paths from=funds to=aREa length=5
## ### Failing; no paths at all
trace paths from=xx to=yy length=5
## ### Failing; no paths
trace paths from=Funds to=yy length=5
trace paths from=xx to=Property length=5
## ### Implicit multiple
trace paths from=High to=Damage length=5
## ### Explicit multiple
trace paths from=High to=Property | Business length=5
trace paths from=High to=Property OR Business length=5
## Should this be possible?
trace paths from=High to=c("Property", "Business") length=5
trace paths from=Capabilities to=[OP3] length=2
trace paths from=Funds to=area length=5

Robustness

## Joining, by = "label"
trace robustness from=High to=Damage length=5
wrap factors
## Joining, by = "label"
## # A tibble: 3 x 2
##   row_names            `High rainfall <U+0001F327>`
##   <chr>                            <dbl>
## 1 All targets                          1
## 2 Damage to Businesses                 1
## 3 Damage to Property                   1
## Joining, by = "label"
trace robustness from=Capabilities to=[OP3] length=2
wrap factors
## Joining, by = "label"
trace robustness from=Capabilities to=[OP3 length=2
wrap factors
## Joining, by = "label"
## # A tibble: 1 x 6
##   row_names   `All origins` `Capabilities; [~ `Capabilities; [~ `Capabilities; ~
##   <chr>               <dbl>             <dbl>             <dbl>            <dbl>
## 1 Outcomes; ~            11                 6                 2                2
## # ... with 1 more variable:
## #   Capabilities; [P18] Expertise/knowledge for holistic wellbeing <dbl>
## Joining, by = "label"
## # A tibble: 5 x 7
##   row_names   `All origins` `~Capabilities; [~ `Capabilities; ~ `Capabilities; ~
##   <chr>               <dbl>              <dbl>            <dbl>            <dbl>
## 1 All targets            18                  1                7                4
## 2 Outcomes; ~             1                  0                0                0
## 3 Outcomes; ~             4                  1                1                1
## 4 Outcomes; ~             2                  0                0                2
## 5 Outcomes; ~            11                  1                7                4
## # ... with 2 more variables:
## #   Capabilities; [P15] CCMP: Envisioning the Church <dbl>,
## #   Capabilities; [P18] Expertise/knowledge for holistic wellbeing <dbl>
## Joining, by = "label"
## # A tibble: 1 x 2
##   row_names                                                `Capabilities; [P13]~
##   <chr>                                                                    <dbl>
## 1 Outcomes; [OP3] Diversification of livelihood activities                     6
## Joining, by = "label"
trace robustness from=High to=People moving length=5
## Joining, by = "label"
trace robustness from=High to= length=5
## Joining, by = "label"
row_names External factor; High rainfall
Outcome; People moving away from the area 2
## Joining, by = "label"
row_names External factor; High rainfall
Flooding 3
## Joining, by = "label"
row_names External factor; High rainfall
All targets 3
Damage to businesses 1
Damage to property 2
## Joining, by = "label"
row_names All origins External factor; High rainfall External factor; Loss of forests
All targets 3 3 1
Damage to businesses 1 1 1
Damage to property 2 2 1
## Joining, by = "label"
row_names All origins External factor; High rainfall External factor; Loss of forests
All targets 3 3 1
Outcome; People moving away from the area 2 2 1
Outcome; Social things; People get angry 1 1 1

Robustness by field

Just one source:

## Joining, by = "label"
##                              rowname Funds from Orgx
## 1 Increased investment into the area               1

Check that opposites colouring is always preserved?

## Joining, by = "label"
trace robustness from=Revision to=happy length=5
combine opposites
combine opposites
find factors value=exam
combine opposites
zoom factors
find factors value=exam
select factors top=2
select links top=3

Colours in interactive map

combine opposites
zoom factors

Cluster factors

cluster factors clusters=c
cluster factors clusters=c

Pipe-able:

cluster factors clusters=c
cluster factors clusters=c
cluster factors clusters=Rising

Data manipulation, file management etc

Accessing the data

One column in one table

x
  1. Poor economy
(IEA) Poverty
(BF) Started, expanded or invested in business [P]
(BF) Stopped/reduced piece work ‘ganyu’ [P]
(IEA) Increased income [P]
(IEA) Increased purchasing power [P]
(IEA) Increased savings/loans [P]
(IEA) Increased financial knowledge [P]
(RW) Improved gender equality in household [P]
(IEA) Increased economic independence [P]
(IEA) No longer borrows from community members [P]
(RW) Increased resilience [P]
  1. Economic migration [N]
(RW) Reduction in household size
(RW) Moved to live with relative

Merging two maps

color factors field=map_id
color links field=map_id fun=unique

Note warning if factor labels are shared

## Warning in merge_mapfile(graf, map2): Factor labels are shared!
merge mapfile path=example2
color factors field=map_id
color links field=map_id fun=unique

Editing maps directly

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

Editing maps with pipe_update_mapfile

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

Coercing to a standard mapfile:

## Warning: Unreplaced values treated as NA as .x is not compatible. Please specify
## replacements exhaustively or supply .default

## Warning: Unreplaced values treated as NA as .x is not compatible. Please specify
## replacements exhaustively or supply .default

Printing the filters

You can also load up an Excel file: