Skip to contents

Fields may be from the original data and/or fields created by the app, e.g. `n` (frequency). When field is 'label', 'value' can contain a vector of search terms separated by ' OR '.

Text searches are case-insensitive.

Usage

pipe_find_factors(
  graf,
  field = "label",
  value,
  operator = "contains",
  up = 1,
  down = 1,
  remove_isolated = F,
  highlight_only = F
)

Arguments

field

Field (column, variable) to search

value

Value to search for

operator

c('contains','notcontains','=','notequals','greater','less','starts','ends'). How to search.

up

integer. Default is 0.

down

integer. Default is 0.

Value

A mapfile containing only matching factors; if `up`!=0 then also factors this number of steps upstream of the matching factors are also included and likewise for `down`!=0. The links are filtered correspondingly to return only the "ego network" i.e. links between the returned factors. If operator and field are both NULL, the value is treated as a simple search string for the field `label`.

Examples

pipe_find_factors(example2,field="label",value="Flood",operator="contains")
#> find factors
#> make info
#> pipe update
#> make info
#> pipe update
#> pipe update
#> finalise
#> pipe update
#> finalise transforms
#> recalc all
#> make info
#> pipe recalc factors
#> make info
#> finalise
#> make info
#> pipe update
#> finalise
#> pipe update
#> finalise
#> pipe update
#> recalc links
#> $factors
#> # A tibble: 8 x 29
#>   label       id    factor_note factor_id0 factor_memo factor_map_id betweenness
#>   <chr>       <chr> <lgl>            <int> <chr>               <int>       <dbl>
#> 1 "Better fl~ 6     NA                   1 ""                      1           2
#> 2 "Damage to~ 4     NA                   3 ""                      1           0
#> 3 "Damage to~ 3     NA                   4 ""                      1           0
#> 4 "Flood ris~ 7     NA                   5 ""                      1           2
#> 5 "Flooding ~ 2     NA                   6 ""                      1           2
#> 6 "Funds fro~ 5     NA                   7 ""                      1           0
#> 7 "High rain~ 1     NA                   8 ""                      1           0
#> 8 "Increased~ 8     NA                   9 ""                      1           0
#> # ... with 22 more variables: betweenness_rank <dbl>, in_degree <dbl>,
#> #   out_degree <dbl>, frequency <dbl>, size <dbl>, found <lgl>,
#> #   found_type <chr>, map_id <int>, is_flipped <lgl>, role <dbl>,
#> #   driver_score <dbl>, outcome_score <dbl>, driver_rank <int>,
#> #   outcome_rank <int>, is_opposable <lgl>, zoom_level <dbl>,
#> #   top_level_label <chr>, top_level_frequency <dbl>, factor_id <int>,
#> #   from_source_count <dbl>, to_source_count <dbl>, source_count <dbl>
#> 
#> $links
#> # A tibble: 6 x 62
#>   from_label  to_label statement_id quote simple_bundle bundle  from    to note 
#>   <chr>       <chr>           <int> <chr> <chr>         <chr>  <int> <int> <lgl>
#> 1 "High rain~ "Floodi~            1 Rece~ "High rainfa~ "High~     8     6 NA   
#> 2 "Flooding ~ "Damage~            1 The ~ "Flooding \U~ "Floo~     6     4 NA   
#> 3 "Flooding ~ "Damage~            1 The ~ "Flooding \U~ "Floo~     6     3 NA   
#> 4 "Funds fro~ "Better~            1 Fund~ "Funds from ~ "Fund~     7     1 NA   
#> 5 "Better fl~ "Flood ~            1 bett~ "Better floo~ "Bett~     1     5 NA   
#> 6 "Flood ris~ "Increa~            1 redu~ "Flood risk ~ "Floo~     5     9 NA   
#> # ... with 53 more variables: link_id0 <int>, link_id <int>, weight <int>,
#> #   strength <int>, certainty <int>, from_flipped <lgl>, to_flipped <lgl>,
#> #   link_label <chr>, hashtag <chr>, link_memo <chr>, link_map_id <int>,
#> #   s.text <chr>, s.statement_note <lgl>, s.#QuestionID <lgl>,
#> #   s.#SourceID <lgl>, s.statement_memo <chr>, s.source_id <chr>,
#> #   s.question_id <chr>, s.statement_map_id <dbl>, s.factor_id <int>,
#> #   s.r.source_memo <chr>, s.r.source_map_id <dbl>, ...
#> 
#> $statements
#> # A tibble: 2 x 21
#>   statement_id text      statement_note `#QuestionID` `#SourceID` statement_memo
#>          <dbl> <chr>     <lgl>          <lgl>         <lgl>       <chr>         
#> 1            1 Welcome ~ NA             NA            NA          st memo       
#> 2            2 Rising s~ NA             NA            NA          NA            
#> # ... with 15 more variables: statement_map_id <dbl>, factor_id <int>,
#> #   r.source_memo <chr>, r.source_map_id <dbl>, q.question_text <chr>,
#> #   q.question_memo <chr>, q.question_map_id <dbl>, label <dbl>,
#> #   source_id <chr>, source_memo <chr>, source_map_id <dbl>, question_id <chr>,
#> #   question_text <chr>, question_memo <chr>, question_map_id <dbl>
#> 
#> $sources
#> # A tibble: 1 x 3
#>   source_id source_memo source_map_id
#>   <chr>     <chr>               <dbl>
#> 1 1         ooh                     1
#> 
#> $questions
#> # A tibble: 1 x 4
#>   question_id question_text   question_memo question_map_id
#>   <chr>       <chr>           <chr>                   <dbl>
#> 1 1           global question q memo                      1
#> 
#> $settings
#> # A tibble: 1 x 3
#>   setting_id        value map_id
#>   <chr>             <chr> <chr> 
#> 1 background_colour NA    1     
#> 
#> attr(,"info")
#> attr(,"info")$pipe_find_factors
#> attr(,"info")$pipe_find_factors[[1]]
#> pipe_find_factors
#> 
#> attr(,"info")$pipe_find_factors$graf
#> example2
#> 
#> attr(,"info")$pipe_find_factors$field
#> [1] "label"
#> 
#> attr(,"info")$pipe_find_factors$value
#> [1] "Flood"
#> 
#> attr(,"info")$pipe_find_factors$operator
#> [1] "contains"
#> 
#> 
#> attr(,"info")$pipe_recalculate_factors
#> attr(,"info")$pipe_recalculate_factors[[1]]
#> pipe_recalculate_factors
#> 
#> attr(,"info")$pipe_recalculate_factors$graf
#> .
#> 
#> 
#> attr(,"info")$pipe_recalculate_links
#> attr(,"info")$pipe_recalculate_links[[1]]
#> pipe_recalculate_links
#> 
#> attr(,"info")$pipe_recalculate_links$graf
#> .
#> 
#> 
pipe_find_factors(example2,value="Flood") %>% make_interactive_map
#> find factors
#> make info
#> pipe update
#> make info
#> pipe update
#> pipe update
#> finalise
#> pipe update
#> finalise transforms
#> recalc all
#> make info
#> pipe recalc factors
#> make info
#> finalise
#> make info
#> pipe update
#> finalise
#> pipe update
#> finalise
#> pipe update
#> recalc links
#> pipe update
#> pipe update
#> fix col factors
#> Error: Problem with `mutate()` column `title`.
#> i `title = paste0(...)`.
#> x could not find function "HTML"
pipe_find_factors(example2,value="Flood")
#> find factors
#> make info
#> pipe update
#> make info
#> pipe update
#> pipe update
#> finalise
#> pipe update
#> finalise transforms
#> recalc all
#> make info
#> pipe recalc factors
#> make info
#> finalise
#> make info
#> pipe update
#> finalise
#> pipe update
#> finalise
#> pipe update
#> recalc links
#> $factors
#> # A tibble: 8 x 29
#>   label       id    factor_note factor_id0 factor_memo factor_map_id betweenness
#>   <chr>       <chr> <lgl>            <int> <chr>               <int>       <dbl>
#> 1 "Better fl~ 6     NA                   1 ""                      1           2
#> 2 "Damage to~ 4     NA                   3 ""                      1           0
#> 3 "Damage to~ 3     NA                   4 ""                      1           0
#> 4 "Flood ris~ 7     NA                   5 ""                      1           2
#> 5 "Flooding ~ 2     NA                   6 ""                      1           2
#> 6 "Funds fro~ 5     NA                   7 ""                      1           0
#> 7 "High rain~ 1     NA                   8 ""                      1           0
#> 8 "Increased~ 8     NA                   9 ""                      1           0
#> # ... with 22 more variables: betweenness_rank <dbl>, in_degree <dbl>,
#> #   out_degree <dbl>, frequency <dbl>, size <dbl>, found <lgl>,
#> #   found_type <chr>, map_id <int>, is_flipped <lgl>, role <dbl>,
#> #   driver_score <dbl>, outcome_score <dbl>, driver_rank <int>,
#> #   outcome_rank <int>, is_opposable <lgl>, zoom_level <dbl>,
#> #   top_level_label <chr>, top_level_frequency <dbl>, factor_id <int>,
#> #   from_source_count <dbl>, to_source_count <dbl>, source_count <dbl>
#> 
#> $links
#> # A tibble: 6 x 62
#>   from_label  to_label statement_id quote simple_bundle bundle  from    to note 
#>   <chr>       <chr>           <int> <chr> <chr>         <chr>  <int> <int> <lgl>
#> 1 "High rain~ "Floodi~            1 Rece~ "High rainfa~ "High~     8     6 NA   
#> 2 "Flooding ~ "Damage~            1 The ~ "Flooding \U~ "Floo~     6     4 NA   
#> 3 "Flooding ~ "Damage~            1 The ~ "Flooding \U~ "Floo~     6     3 NA   
#> 4 "Funds fro~ "Better~            1 Fund~ "Funds from ~ "Fund~     7     1 NA   
#> 5 "Better fl~ "Flood ~            1 bett~ "Better floo~ "Bett~     1     5 NA   
#> 6 "Flood ris~ "Increa~            1 redu~ "Flood risk ~ "Floo~     5     9 NA   
#> # ... with 53 more variables: link_id0 <int>, link_id <int>, weight <int>,
#> #   strength <int>, certainty <int>, from_flipped <lgl>, to_flipped <lgl>,
#> #   link_label <chr>, hashtag <chr>, link_memo <chr>, link_map_id <int>,
#> #   s.text <chr>, s.statement_note <lgl>, s.#QuestionID <lgl>,
#> #   s.#SourceID <lgl>, s.statement_memo <chr>, s.source_id <chr>,
#> #   s.question_id <chr>, s.statement_map_id <dbl>, s.factor_id <int>,
#> #   s.r.source_memo <chr>, s.r.source_map_id <dbl>, ...
#> 
#> $statements
#> # A tibble: 2 x 21
#>   statement_id text      statement_note `#QuestionID` `#SourceID` statement_memo
#>          <dbl> <chr>     <lgl>          <lgl>         <lgl>       <chr>         
#> 1            1 Welcome ~ NA             NA            NA          st memo       
#> 2            2 Rising s~ NA             NA            NA          NA            
#> # ... with 15 more variables: statement_map_id <dbl>, factor_id <int>,
#> #   r.source_memo <chr>, r.source_map_id <dbl>, q.question_text <chr>,
#> #   q.question_memo <chr>, q.question_map_id <dbl>, label <dbl>,
#> #   source_id <chr>, source_memo <chr>, source_map_id <dbl>, question_id <chr>,
#> #   question_text <chr>, question_memo <chr>, question_map_id <dbl>
#> 
#> $sources
#> # A tibble: 1 x 3
#>   source_id source_memo source_map_id
#>   <chr>     <chr>               <dbl>
#> 1 1         ooh                     1
#> 
#> $questions
#> # A tibble: 1 x 4
#>   question_id question_text   question_memo question_map_id
#>   <chr>       <chr>           <chr>                   <dbl>
#> 1 1           global question q memo                      1
#> 
#> $settings
#> # A tibble: 1 x 3
#>   setting_id        value map_id
#>   <chr>             <chr> <chr> 
#> 1 background_colour NA    1     
#> 
#> attr(,"info")
#> attr(,"info")$pipe_find_factors
#> attr(,"info")$pipe_find_factors[[1]]
#> pipe_find_factors
#> 
#> attr(,"info")$pipe_find_factors$graf
#> example2
#> 
#> attr(,"info")$pipe_find_factors$value
#> [1] "Flood"
#> 
#> 
#> attr(,"info")$pipe_recalculate_factors
#> attr(,"info")$pipe_recalculate_factors[[1]]
#> pipe_recalculate_factors
#> 
#> attr(,"info")$pipe_recalculate_factors$graf
#> .
#> 
#> 
#> attr(,"info")$pipe_recalculate_links
#> attr(,"info")$pipe_recalculate_links[[1]]
#> pipe_recalculate_links
#> 
#> attr(,"info")$pipe_recalculate_links$graf
#> .
#> 
#> 
pipe_find_factors(example2,field="id",value=5,operator="greater")
#> find factors
#> make info
#> Error in if (df$found %>% sum %>% ==0) {    graf <- (pipe_update_mapfile(graf, factors = graf$factors %>%         filter(F), links = graf$links %>% filter(F)))    return(graf %>% pipe_recalculate_all())}: missing value where TRUE/FALSE needed