Skip to content

Commit

Permalink
Added an alternative way to download files directly from Avoin data
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Kainu committed Aug 26, 2024
1 parent 127cc1f commit 0ae774b
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: kelaopendata
Type: Package
Title: Access open data from National social insurance institution of Finland
Version: 0.1.0002
Date: 2024-06-06
Version: 0.1.1
Date: 2024-08-26
Author: Markus Kainu
Maintainer: Markus Kainu <[email protected]>
Description: Designed to simplify and speed up access to open data from National social insurance institution of Finland (KELA) published at <https://www.avoindata.fi/data/fi/organization/kela>, the kelaopendata package offers researchers and analysts a set of tools to obtain data and metadata for a wide range of applications.
Expand All @@ -21,4 +21,4 @@ Imports:
glue
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

export(get_csv_links)
export(get_data)
export(get_data_csv)
export(get_metadata)
export(list_ckan)
export(list_datasets)
Expand All @@ -20,3 +21,4 @@ importFrom(dplyr,filter)
importFrom(dplyr,mutate)
importFrom(glue,glue)
importFrom(jsonlite,fromJSON)
importFrom(readr,read_csv)
5 changes: 5 additions & 0 deletions R/onAttach.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.onAttach <- function(lib, pkg) {
packageStartupMessage(paste0("kelaopendata ",
utils::packageVersion("kelaopendata"),
": Access open data from Kela.\nhttps://github.com/ropengov/kelaopendata\nData is licensed under CC-BY 4.0. Please give appropriate attribution to Kela when using data."))
}
23 changes: 23 additions & 0 deletions R/read_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,29 @@ get_data <- function(data_id, sql = NA){
}


#' Download the whole data set using csv-files
#'
#' @param data_id data id
#'
#' @return tibble
#' @export
#'
#' @importFrom readr read_csv
#' @importFrom dplyr as_tibble
#' @importFrom dplyr %>%
#'
get_data_csv <- function(data_id){

pkg_lst <- pick_a_pkg(input_dataset = data_id)

csv_links <- get_csv_links(pkg_lst = pkg_lst)

flst <- lapply(csv_links, readr::read_csv)
res <- do.call('rbind', flst) |> as_tibble()
return(res)
}





Expand Down
17 changes: 17 additions & 0 deletions man/get_data_csv.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0ae774b

Please sign in to comment.