Returns a data frame/tibble from the URL of a given BFS PC-Axis file. The default language is German and the column names are renamed using the clean_names function of the janitor package. If the path of the cache argument is not provided, the downloaded BFS dataset will be saved in the default cache folder of the pins package. The metadata can be accessed by making the downloaded dataset an argument of the base R function attributes().

bfs_get_dataset(
  url_px,
  language = "de",
  path = pins::board_cache_path(),
  force = FALSE
)

Arguments

url_px

The url link to download the PC-Axis file.

language

Language of the dataset to be translated if exists.

path

The local folder to use as a cache, default to pins cache.

force

Force download to download data even if already downloaded today.

Details

The BFS data is saved in a local folder using the pins package. The function allows to download the BFS data only once per day. If the data has alread been downloaded during the day, the existing dataset is loaded into R from the pins caching folder instead of downloading again the data from the BFS website.

See also

Examples

meta_en <- bfs_get_metadata(language = "en") bfs_meta_edu <- bfs_search(data = meta_en, pattern = "university students") bfs_get_dataset(bfs_meta_edu$url_px[1], language = "en")
#> # A tibble: 16,800 x 5 #> level_of_study gender isced_field year value #> <fct> <fct> <fct> <fct> <dbl> #> 1 First university degree or diploma Male Education scien… 2019/… 46 #> 2 Bachelor Male Education scien… 2019/… 149 #> 3 Master Male Education scien… 2019/… 131 #> 4 Doctorate Male Education scien… 2019/… 120 #> 5 Further education, advanced studies and… Male Education scien… 2019/… 14 #> 6 First university degree or diploma Female Education scien… 2019/… 62 #> 7 Bachelor Female Education scien… 2019/… 696 #> 8 Master Female Education scien… 2019/… 540 #> 9 Doctorate Female Education scien… 2019/… 313 #> 10 Further education, advanced studies and… Female Education scien… 2019/… 24 #> # … with 16,790 more rows