Git Product home page Git Product logo

r_package_to_api_bdl's Introduction

bdl 1.0.5.9001

CRAN status R-CMD-check

Overview

The bdl package is an interface to Local Data Bank (Bank Danych Lokalnych - bdl) API. It is a set of tools that includes: quick plots and maps generation, with the usage of the datasets from the data bank.

The information about how to use this tool is included in the built-in R help documentation and on the package webpage https://statisticspoland.github.io/R_Package_to_API_BDL/.

Try

help(p = "bdl")

More info about the metadata can be found at https://bdl.stat.gov.pl/BDL/start.

Installation

To install this package run these commands:

Windows and Mac

# install.packages("remotes", type = "binary")
remotes::install_github("statisticspoland/R_Package_to_API_BDL", upgrade = "always", type = "binary")

Linux

# install.packages("remotes")
remotes::install_github("statisticspoland/R_Package_to_API_BDL")

If installation through remotes do not work, try installing the package manually by downloading the source package at https://github.com/statisticspoland/R_Package_to_API_BDL/releases/download/1.0.5/bdl_1.0.5.zip and executing

install.packages("path_to_file/bdl_1.0.5.zip", repos = NULL, type = "source")

r_package_to_api_bdl's People

Contributors

bienkowskaa avatar iwoa avatar kaniakrzysztof avatar marcinkosinski avatar marzenaszpadel avatar nowosad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

r_package_to_api_bdl's Issues

Pakiet BDL, a antywirus

Dzień dobry,
mam problem z zainstalowaniem pakietu BDL, w R Studio. Przy instalacji występuje błąd, ponieważ antywirus wykrywa zagrożenie i nie pozwala dokończyć instalacji pakietu. Co w tym wypadku należy zrobić, tak, żeby nie było potrzeby wyłączać antywirusa?

błąd_bdl.pdf

Substitute plyr::join_all with purrr::reduce

Under this SO question one can see the equivalent for plyr::join_all which is purrr:reduce.

> library(plyr)
> dfs <- list(
+   a = data.frame(x = 1:10, a = runif(10)),
+   b = data.frame(x = 1:10, b = runif(10)),
+   c = data.frame(x = 1:10, c = runif(10))
+ )
> join_all(dfs, "x")
    x          a         b         c
1   1 0.57119390 0.2653866 0.5130320
2   2 0.88501253 0.3914206 0.5990092
3   3 0.97230620 0.7255818 0.1687517
4   4 0.19460068 0.1252290 0.1923817
5   5 0.69917449 0.1464009 0.3980751
6   6 0.78650351 0.7987320 0.6369933
7   7 0.99910259 0.3822278 0.9299816
8   8 0.06227989 0.2037727 0.2606305
9   9 0.71419857 0.1844163 0.2498298
10 10 0.45508120 0.9791452 0.9281774
> 
> library(dplyr)
> purrr::reduce(dfs, left_join)
Joining, by = "x"
Joining, by = "x"
    x          a         b         c
1   1 0.57119390 0.2653866 0.5130320
2   2 0.88501253 0.3914206 0.5990092
3   3 0.97230620 0.7255818 0.1687517
4   4 0.19460068 0.1252290 0.1923817
5   5 0.69917449 0.1464009 0.3980751
6   6 0.78650351 0.7987320 0.6369933
7   7 0.99910259 0.3822278 0.9299816
8   8 0.06227989 0.2037727 0.2606305
9   9 0.71419857 0.1844163 0.2498298
10 10 0.45508120 0.9791452 0.9281774

I would recommend removing plyr from the package since it confuse the NAMESPACE with the dplyr package

> library(dplyr)

Attaching package: ‘dplyr’

The following objects are masked from ‘package:plyr’:

    arrange, count, desc, failwith, id, mutate, rename, summarise, summarize

and is not recommended even by the author.

Changes should be made in those places:

is stringi::stri_length really required?

If you'd like to reduce the dependenies amount in your package, you can consider removing packages that you import just to use one function. You could either copy the whole function into your package, or consider some substitution like nchar. nchar() doesn't handle NAs that properly as stringi_length()

> stringi::stri_length('')
[1] 0
> stringi::stri_length('NA')
[1] 2
> stringi::stri_length(NA)
[1] NA
> stringi::stri_length(NULL)
integer(0)
> stringi::stri_length('')
[1] 0
> 
> nchar('NA')
[1] 2
> nchar(NA)
[1] NA
> nchar(NULL)
integer(0)
> nchar('')
[1] 0

but you can always use

nchar_length <- function(x) {`if`(is.na(x), 0, nchar(x)) }; nchar_length(NA); nchar_length(''); nchar_length(''); nchar_length('asdasda')
[1] 0
[1] 0
[1] 0
[1] 7

instead of stringi::stri_length that imports the whole package and makes the user download the whole package during the installation

search_subjects() get_subjects() returns Failure to get data. Error occured. Status code: 500

get_units() and search_units (search_units(name = "wro") etc. work well, however get and search subjects throws an error Status code:500

search_subjects("lud")
Error in get_request(dir, id, filters, ...) :
Failure to get data. Error occured. Status code: 500.

search_subjects(name = "lud")
Error in get_request(dir, id, filters, ...) :
Failure to get data. Error occured. Status code: 500.

search_subjects(name = "lud")
Error in get_request(dir, id, filters, ...) :
Failure to get data. Error occured. Status code: 500.

search_subjects(name = "lud", lang = "pl")
Error in get_request(dir, id, filters, ...) :
Failure to get data. Error occured. Status code: 500.

get_subjects()
Error in get_request(dir, id, filters, ...) :
Failure to get data. Error occured. Status code: 500.

get_subjects(parentId = "011212000000")
Error in get_request(dir, id, filters, ...) :
Failure to get data. Error occured. Status code: 500.

search_subjects("zdrowia")
Error in get_request(dir, id, filters, ...) :
Failure to get data. Error occured. Status code: 500.

get_subjects(Id = "011212000000")
Error in get_request(dir, id, filters, ...) :
Failure to get data. Error occured. Status code: 500.

get_units() and search_units (search_units(name = "wro") etc. work well.

Meaning of territorial unit Id

I have not found a way to understand how the "Territorial unit ID" identifies administrative regions, especially at the locality level where there are no shapefiles / SF geometries to locate them in space in the GIT.

Would be very useful to have a dictionary on how the Territorial Unit ID is constructed (to unite it with other sources such as https://geo.stat.gov.pl/en/inspire Or, even more useful, a (downloadable) SF file that has the same id so data from level 7 can be located in space.

Thanks for your time and sorry if I missed something.

Issues with the installation

On my Ubuntu 18 the instruction suggested in the README

remotes::install_github("statisticspoland/R_Package_to_API_BDL", upgrade = "always", type = "binary")

crashes with

Error in i.p(...) : type 'binary' is not supported on this platform

This one works

remotes::install_github("statisticspoland/R_Package_to_API_BDL")

Failure to get data for variable 54821

Calling bdl::get_data_by_variable(54821, unitLevel = 6, year = 2011) I get the following error

Error in get_request(dir, id = attrId, filters, ...) : 
  Failure to get data. Probably invalid id. Status code: 412.

Traceback:

7: stop("Failure to get data. Probably invalid id. Status code: ", 
       status, msg)
6: get_request(dir, id = attrId, filters, ...)
5: attribute_info(attrId, lang = lang)
4: FUN(X[[i]], ...)
3: lapply(attributes, get_attr_label, lang = lang)
2: add_attribute_labels(df, lang)
1: bdl::get_data_by_variable(54821, unitLevel = 6, year = 2011)

The error occurs when requesting attributeInfo for attrId = 0. The request is made to https://bdl.stat.gov.pl/api/v1/attributes/0?lang=pl&page-Size=100&format=json which is invalid.

There is one row in the dataframe attributeIds are taken from with attrId = 0:

# A tibble: 1 x 5
  id           name                                  year    val attrId
  <chr>        <chr>                                 <chr> <int>  <int>
1 071412865998 GMINY-DZIELNICY WARSZAWY NIE USTALONO 2011      0      0

The repository name

R_Package_to_API_BDL seems tought. Why not using some catchy name for the repository, that relates to the short name of the package? A repository could be named statisticspoland/rbld where the package, while still in the development phrase could also by renamed to rbld. Think about the other interface for other language that would probably can be named after laguages like
py-bdl and so on. With the rbld in the name, you not only have the catchy meanigful name for the repository but also you can distinguish between the bld package for R, Python and other languages.

Just a though, but it's better to solve this at the early beginning

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.