---
title: "Listing the essential data"
author: "Carlos YANEZ SANTIBANEZ"
date: "2022-11-28"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Listing the essential data}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---



To get started, it is good to know in advance the division to analyse, parties in the race, etc. The *list_* family of functions will help you to get to bearings before getting and analysing the data. The functions include here are:

- list_years()
- list_divisions()
- list_parties()
- list_polling_places()

## Years and divisions

To figure out the election results included in the package, just run:


```r
list_years()
#> [1] 2022 2019 2016 2013 2010 2007 2004
```

To retrieve the list of divisions for all the years, you can run *list_divisions*:


```r
list_divisions()
#> # A tibble: 167 × 10
#>    StateAb DivisionID DivisionNm `2022` `2019` `2016` `2013` `2010` `2007` `2004`
#>    <chr>        <int> <chr>      <lgl>  <lgl>  <lgl>  <lgl>  <lgl>  <lgl>  <lgl> 
#>  1 ACT            101 Canberra   TRUE   TRUE   TRUE   TRUE   TRUE   TRUE   TRUE  
#>  2 ACT            102 Fenner     TRUE   TRUE   TRUE   NA     NA     NA     NA    
#>  3 ACT            102 Fraser     NA     NA     NA     TRUE   TRUE   TRUE   TRUE  
#>  4 ACT            318 Bean       TRUE   TRUE   NA     NA     NA     NA     NA    
#>  5 NSW            103 Banks      TRUE   TRUE   TRUE   TRUE   TRUE   TRUE   TRUE  
#>  6 NSW            104 Barton     TRUE   TRUE   TRUE   TRUE   TRUE   TRUE   TRUE  
#>  7 NSW            105 Bennelong  TRUE   TRUE   TRUE   TRUE   TRUE   TRUE   TRUE  
#>  8 NSW            106 Berowra    TRUE   TRUE   TRUE   TRUE   TRUE   TRUE   TRUE  
#>  9 NSW            107 Blaxland   TRUE   TRUE   TRUE   TRUE   TRUE   TRUE   TRUE  
#> 10 NSW            108 Bradfield  TRUE   TRUE   TRUE   TRUE   TRUE   TRUE   TRUE  
#> # … with 157 more rows
```

This function allows for some filtering by using a list containing any of the columns included:


```r
list_divisions(filter=list(DivisionNm=c("Batman","Cooper")))
#> # A tibble: 2 × 10
#>   StateAb DivisionID DivisionNm `2022` `2019` `2016` `2013` `2010` `2007` `2004`
#>   <chr>        <int> <chr>      <lgl>  <lgl>  <lgl>  <lgl>  <lgl>  <lgl>  <lgl> 
#> 1 VIC            199 Batman     NA     NA     TRUE   TRUE   TRUE   TRUE   TRUE  
#> 2 VIC            320 Cooper     TRUE   TRUE   NA     NA     NA     NA     NA
```

## Political Parties

It is recommended to explore the list of parties that have participated in the elections in the data. For this **


```r

list_parties()
#> # A tibble: 387 × 10
#>    StateAb PartyAb PartyNm                                  `2016` `2019` `2004` `2010` `2013` `2022` `2007`
#>    <chr>   <chr>   <chr>                                    <lgl>  <lgl>  <lgl>  <lgl>  <lgl>  <lgl>  <lgl> 
#>  1 NSW     AAPP    Antipaedophile Party                     TRUE   NA     NA     NA     NA     NA     NA    
#>  2 NSW     ABFA    Australian Better Families               NA     TRUE   NA     NA     NA     NA     NA    
#>  3 VIC     ADP     The Aged and Disability Pensioners Party NA     NA     TRUE   NA     NA     NA     NA    
#>  4 NSW     ADVP    Veterans Party                           TRUE   NA     NA     NA     NA     NA     NA    
#>  5 QLD     ADVP    Veterans Party                           TRUE   NA     NA     NA     NA     NA     NA    
#>  6 VIC     AEQ     Marriage Equality                        TRUE   NA     NA     NA     NA     NA     NA    
#>  7 NSW     AFN     Australia First Party                    TRUE   TRUE   NA     TRUE   TRUE   NA     NA    
#>  8 NT      AFN     Australia First Party                    TRUE   NA     NA     NA     NA     NA     NA    
#>  9 QLD     AFN     Australia First Party                    NA     TRUE   NA     NA     NA     NA     NA    
#> 10 SA      AFN     Australia First Party                    NA     NA     NA     NA     TRUE   NA     NA    
#> # … with 377 more rows
```

Due to changes in parties and the federal nature of the country, parties may have different names in different places and they may change over time. In addition to a filter argument (like in list_divisions), this function also allows filtering by party names using  a [regular expression](https://en.wikipedia.org/wiki/Regular_expression), e.g.:


```r
list_parties(party_regex = "Greens")
#> # A tibble: 17 × 10
#>    StateAb PartyAb PartyNm                                    `2004` `2007` `2010` `2013` `2016` `2019` `2022`
#>    <chr>   <chr>   <chr>                                      <lgl>  <lgl>  <lgl>  <lgl>  <lgl>  <lgl>  <lgl> 
#>  1 ACT     GRN     The Greens                                 TRUE   TRUE   TRUE   NA     TRUE   TRUE   TRUE  
#>  2 ACT     GRN     Australian Greens                          NA     NA     NA     TRUE   NA     NA     NA    
#>  3 NSW     GRN     The Greens                                 TRUE   TRUE   TRUE   TRUE   TRUE   TRUE   TRUE  
#>  4 NT      GRN     The Greens                                 TRUE   TRUE   TRUE   NA     TRUE   TRUE   TRUE  
#>  5 NT      GRN     Australian Greens                          NA     NA     NA     TRUE   NA     NA     NA    
#>  6 QLD     GRN     The Greens                                 TRUE   TRUE   TRUE   TRUE   TRUE   TRUE   NA    
#>  7 QLD     GRN     Queensland Greens                          NA     NA     NA     NA     NA     NA     TRUE  
#>  8 SA      GRN     The Greens                                 TRUE   TRUE   TRUE   NA     TRUE   TRUE   TRUE  
#>  9 SA      GRN     Australian Greens                          NA     NA     NA     TRUE   NA     NA     NA    
#> 10 TAS     GRN     Australian Greens                          TRUE   NA     TRUE   TRUE   NA     NA     NA    
#> 11 TAS     GRN     The Greens                                 NA     TRUE   NA     NA     TRUE   TRUE   TRUE  
#> 12 VIC     GRN     Australian Greens                          TRUE   TRUE   TRUE   NA     NA     NA     NA    
#> 13 VIC     GRN     The Greens                                 NA     NA     NA     TRUE   TRUE   NA     TRUE  
#> 14 VIC     GRN     The Greens (VIC)                           NA     NA     NA     NA     NA     TRUE   NA    
#> 15 WA      GRN     The Greens                                 TRUE   TRUE   TRUE   NA     NA     NA     NA    
#> 16 WA      GRN     The Greens (WA)                            NA     NA     NA     TRUE   TRUE   TRUE   TRUE  
#> 17 WA      ODR     Outdoor Recreation Party (Stop The Greens) NA     NA     NA     NA     TRUE   NA     NA
```

## Polling places

Finally, it is possible to list all polling places, showing their active years. For example, for all the electorates in Bennelong


```r
list_polling_places(filters=list(DivisionNm="Bennelong"))
#> # A tibble: 126 × 16
#>    State DivisionID DivisionNm PollingPlaceID PollingPlaceTypeID PremisesNm                     Pollin…¹ Latit…² Longi…³ `2004` `2007` `2010` `2013` `2016` `2019` `2022`
#>    <chr>      <int> <chr>               <int>              <int> <chr>                          <chr>      <dbl>   <dbl> <lgl>  <lgl>  <lgl>  <lgl>  <lgl>  <lgl>  <lgl> 
#>  1 NSW          105 Bennelong              75                  1 Epping Boys High School        Balacla…   -33.8    151. TRUE   TRUE   TRUE   TRUE   TRUE   TRUE   TRUE  
#>  2 NSW          105 Bennelong              75                  1 Epping Boys High School        Marsfie…   -33.8    151. TRUE   TRUE   TRUE   TRUE   TRUE   TRUE   TRUE  
#>  3 NSW          105 Bennelong              79                  1 Australian Air League Building Eastview   -33.8    151. TRUE   TRUE   TRUE   TRUE   TRUE   TRUE   NA    
#>  4 NSW          105 Bennelong              79                  1 Australian Air League Building Ryde       -33.8    151. TRUE   TRUE   TRUE   TRUE   TRUE   TRUE   NA    
#>  5 NSW          105 Bennelong              79                  1 The Living Way Church          Ryde       -33.8    151. NA     NA     NA     NA     NA     NA     TRUE  
#>  6 NSW          105 Bennelong              80                  1 Eastwood Heights Public School Eastwoo…   -33.8    151. TRUE   TRUE   TRUE   TRUE   TRUE   TRUE   TRUE  
#>  7 NSW          105 Bennelong              81                  1 Epping Community Centre        Epping …   -33.8    151. TRUE   TRUE   TRUE   NA     NA     NA     NA    
#>  8 NSW          105 Bennelong              81                  1 Epping Public School           Epping …   -33.8    151. NA     NA     NA     TRUE   TRUE   TRUE   TRUE  
#>  9 NSW          105 Bennelong              82                  1 Epping North Public School     Epping …   -33.8    151. TRUE   TRUE   TRUE   TRUE   TRUE   TRUE   TRUE  
#> 10 NSW          105 Bennelong              84                  1 Gladesville Public School      Gladesv…   -33.8    151. TRUE   TRUE   TRUE   TRUE   TRUE   TRUE   TRUE  
#> # … with 116 more rows, and abbreviated variable names ¹​PollingPlaceNm, ²​Latitude, ³​Longitude
```
