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:
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
Simple frequency
find links field=simple_frequency value=50 operator=greater
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
Label links
label links field=link_id fun=literal add_field_name=T
label links field=link_id fun=literal
label links field=from_label fun=literal add_field_name=T clear_previous=F
bundle links
label links field=link_id fun=literal add_field_name=T
bundle links
label links field=link_id fun=literal
label links field=from_label fun=literal clear_previous=F
bundle links
label links field=statement_id fun=unique clear_previous=F
Bundling links
Note the defaults for bundle_links and label_links:
find factors value=economic
select factors top=5
bundle links
label links
find factors value=economic
select factors top=5
bundle links
label links
Note the default for bundle_links is equivalent to simple_bundle:
find factors value=economic
select factors top=5
bundle links group=simple_bundle
label links
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
select links top=16
bundle links field=1. Sex
label links field=link_id fun=count
Group by sex and scale and colour by count:
select factors top=5
bundle links field=1. Sex
color links field=link_id fun=count
scale links field=link_id fun=count
label links field=link_id fun=count
Proportion
## Warning in as_numeric_if_all(vec): NAs introduced by coercion
find factors value=sed yield
bundle links field=District
color links field=District fun=unique
label links value=percent: link_id
scale links field=link_id fun=count
## Warning in as_numeric_if_all(vec): NAs introduced by coercion
find factors value=sed yield
bundle links field=1. Sex
color links field=1. Sex fun=unique
label links field=link_id fun=percent
scale links field=link_id fun=count
## Warning in as_numeric_if_all(vec): NAs introduced by coercion
find factors value=sed yield
bundle links field=1. Sex
color links field=1. Sex fun=unique
label links field=source_id fun=percent
scale links field=source_id fun=percent
find factors value=sed yield down=0
bundle links field=1. Sex
color links field=source_id fun=percent
label links field=source_id fun=percent
scale links field=source_id fun=count
Surprise
## Warning in as_numeric_if_all(vec): NAs introduced by coercion
find factors value=sed yield down=0
bundle links field=1. Sex
color links field=1. Sex fun=unique
label links field=source_id fun=surprise
scale links field=source_id fun=count
find factors value=sed yield down=0
bundle links field=1. Sex
label links field=1. Sex fun=unique
color links field=source_id fun=surprise
scale links field=source_id fun=count
Mark links
## Note: Using an external vector in selections is ambiguous.
## i Use `all_of(ogroups)` instead of `ogroups` to silence this message.
## i See <https://tidyselect.r-lib.org/reference/faq-external-vector.html>.
## This message is displayed once per session.
label links field=source_id fun=literal
mark links field=source_id
label links field=source_id fun=literal
mark links field=source_id
label links field=source_id fun=literal
mark links field=source_id
bundle links field=source_id
label links field=source_id fun=literal
mark links field=source_id
combine opposites
bundle links field=flipped_bundle
label links field=source_id fun=literal
mark links field=source_id
select factors top=5
bundle links field=simple_bundle
mark links field=source_id
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
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
Data manipulation, file management etc
Accessing the data
One column in one table
|
x
|
- 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]
|
- 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: