Skip to contents

A parser which breaks a text input into individual commands and sends each command to one of the family of pipe_* functions.

Usage

parse_commands(graf = NULL, tex)

Arguments

graf

A mapfile representing a causal map. A mapfile is a tidygraph, which consists of a table of edges linked to a table of nodes, with an optional additional table of statements. In this package, nodes are called `factors` and edges are called `links.`

tex

A set of commands to parse, separated by linebreaks if there is more than one command. Each line starts with two words corresponding to the name of the pipe function to be applied, e.g. `color links` calls the function `color_links`. The function name is followed by field=value pairs corresponding to the arguments of the function such as `top=10`. Lines beginning with a hash # are treated as comments and ignored.

This parser also provides some abbreviated formats. `find links FIELD OPERATOR VALUE` is parsed as `find links field=FIELD operator=OPERATOR value=VALUE`. `find factors FIELD OPERATOR VALUE` is parsed as `find factors field=FIELD operator=OPERATOR value=VALUE`. `search factors TEXT ...` is parsed as `search factors field=label value=TEXT operator=contains`. `search links TEXT ...` is parsed as `search links field=label value=TEXT operator=contains`. `search statements TEXT ...` is parsed as `search statements field=text value=TEXT operator=contains`.

Value

A mapfile, the result of successively applying the commands to the input graph.

Examples

cashTransferMap %>% parse_commands("select factors top=10 \n color factors field=n") %>% make_vn()
#> Error in make_vn(.): could not find function "make_vn"