Skip to contents

Augments data with additional columns holding URLs of the specified types. The new columns will be named after types, prefixed with url_, so types = "sudd" will add the column url_sudd etc.

Usage

add_urls(data, types = c("sudd", "swissvotes"))

Arguments

data

RDB referendum data as returned by rfrnds(). A data frame that at minimum contains the column id_sudd for types = "sudd" and the columns country_code, level and id_official for types = "swissvotes".

types

Type(s) of URLs to add. One of "sudd" or "swissvotes".

Value

A tibble.

Examples

rdb::rfrnds(quiet = TRUE) |>
  dplyr::filter(country_code == "CH" & level == "national") |>
  rdb::add_urls() |>
  dplyr::select(id,
                country_code,
                level,
                starts_with("id_"),
                starts_with("url_"))
#> # A tibble: 683 × 7
#>    id                       country_code level    id_official id_sudd  url_sudd                              url_swissvotes                
#>    <chr>                    <fct>        <ord>    <chr>       <chr>    <chr>                                 <chr>                         
#>  1 6442587e0b8bae0c78c7e9de CH           national NA          NA       NA                                    NA                            
#>  2 644257630b8bae0c78c7e9da CH           national NA          NA       NA                                    NA                            
#>  3 644255f50b8bae0c78c7e9d6 CH           national NA          NA       NA                                    NA                            
#>  4 63403d2da52c3995043a9208 CH           national 661         ch112022 https://sudd.ch/event.php?id=ch112022 https://swissvotes.ch/vote/661
#>  5 63403a96a52c3995043a91f9 CH           national 658         ch082022 https://sudd.ch/event.php?id=ch082022 https://swissvotes.ch/vote/658
#>  6 634035bba52c3995043a91e2 CH           national 659         ch092022 https://sudd.ch/event.php?id=ch092022 https://swissvotes.ch/vote/659
#>  7 634029b9a52c3995043a91d1 CH           national 660         ch102022 https://sudd.ch/event.php?id=ch102022 https://swissvotes.ch/vote/660
#>  8 62c68fd613bed420d6ffbdf8 CH           national NA          NA       NA                                    NA                            
#>  9 62c689bf13bed420d6ffbdf1 CH           national NA          NA       NA                                    NA                            
#> 10 62c6842013bed420d6ffbdea CH           national NA          NA       NA                                    NA                            
#> # ℹ 673 more rows