Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] More keys than values #250

Closed
gwarnes-mdsol opened this issue Mar 15, 2022 · 1 comment
Closed

[BUG] More keys than values #250

gwarnes-mdsol opened this issue Mar 15, 2022 · 1 comment

Comments

@gwarnes-mdsol
Copy link

gwarnes-mdsol commented Mar 15, 2022

Describe the bug
When attempting to obtain the values corresponding to a list of keys, osmextract::oe_get_keys generates the error Error: There are more keys than values (or vice-versa). Please raise a new issue at https://github.com/ropensci/osmextract

To Reproduce

keys <- osmextract::oe_get_keys('belarus', 'points')
health_keys <- grep('health|hosp', keys, ignore.case = TRUE, value = TRUE)
health_keys
vals <- osmextract::oe_get_keys('belarus', 'points', which_keys = health_keys, values=TRUE)

returns

 [1] "healthcare"                    "healthcare:speciality"         "health_facility:type"         
 [4] "health"                        "was:healthcare"                "construction:healthcare"      
 [7] "health_specialty:dentistry"    "health_specialty:obstetrics"   "health_specialty:traumatology"
[10] "hospital"                      "planned:healthcare"           
 Error: There are more keys than values (or vice-versa). Please raise a new issue at https://github.com/ropensci/osmextract

Expected behaviour

An object containing keys and corresponding values.

Additional context

Session Info ```r devtools::session_info() ─ Session info ───────────────────────────────────────────────────────────── setting value version R version 4.1.1 (2021-08-10) os macOS Monterey 12.2 system x86_64, darwin17.0 ui RStudio language (EN) collate en_US.UTF-8 ctype en_US.UTF-8 tz America/New_York date 2022-03-15 rstudio 2022.02.0+443 Prairie Trillium (desktop) pandoc 2.17.1.1 @ /Applications/RStudio.app/Contents/MacOS/quarto/bin/ (via rmarkdown)

─ Packages ─────────────────────────────────────────────────────────────────
! package * version date (UTC) lib source
P brio 1.1.3 2021-11-30 [?] CRAN (R 4.1.0)
P cachem 1.0.6 2021-08-19 [?] CRAN (R 4.1.0)
P callr 3.7.0 2021-04-20 [?] CRAN (R 4.1.0)
class 7.3-20 2022-01-16 [2] CRAN (R 4.1.3)
P classInt 0.4-3 2020-04-07 [?] CRAN (R 4.1.0)
P cli 3.2.0 2022-02-14 [?] CRAN (R 4.1.2)
P crayon 1.5.0 2022-02-14 [?] CRAN (R 4.1.2)
P curl 4.3.2 2021-06-23 [?] CRAN (R 4.1.0)
P DBI 1.1.2 2021-12-20 [?] CRAN (R 4.1.0)
P desc 1.4.1 2022-03-06 [?] CRAN (R 4.1.2)
P devtools 2.4.3 2021-11-30 [?] CRAN (R 4.1.0)
digest 0.6.27 2020-10-24 [2] CRAN (R 4.1.0)
P e1071 1.7-9 2021-09-16 [?] CRAN (R 4.1.0)
P ellipsis 0.3.2 2021-04-29 [?] CRAN (R 4.1.0)
evaluate 0.14 2019-05-28 [2] CRAN (R 4.1.0)
P fansi 1.0.2 2022-01-14 [?] CRAN (R 4.1.2)
P fastmap 1.1.0 2021-01-25 [?] CRAN (R 4.1.0)
P fs 1.5.2 2021-12-08 [?] CRAN (R 4.1.0)
P glue 1.6.2 2022-02-24 [?] CRAN (R 4.1.2)
VP htmltools 0.5.2 2021-01-22 [?] CRAN (R 4.1.0) (on disk 0.5.1.1)
P httr 1.4.2 2020-07-20 [?] CRAN (R 4.1.0)
jsonlite 1.7.2 2020-12-09 [2] CRAN (R 4.1.0)
KernSmooth 2.23-20 2021-05-03 [2] CRAN (R 4.1.3)
knitr 1.33 2021-04-24 [2] CRAN (R 4.1.0)
lattice 0.20-45 2021-09-22 [2] CRAN (R 4.1.3)
P lifecycle 1.0.1 2021-09-24 [?] CRAN (R 4.1.0)
magrittr 2.0.1 2020-11-17 [2] CRAN (R 4.1.0)
P memoise 2.0.1 2021-11-26 [?] CRAN (R 4.1.0)
P openxlsx 4.2.5 2021-12-14 [?] CRAN (R 4.1.0)
P osmextract 0.4.0 2021-10-27 [?] CRAN (R 4.1.0)
P pillar 1.7.0 2022-02-01 [?] CRAN (R 4.1.2)
P pkgbuild 1.3.1 2021-12-20 [?] CRAN (R 4.1.0)
P pkgconfig 2.0.3 2019-09-22 [?] CRAN (R 4.1.0)
P pkgload 1.2.4 2021-11-30 [?] CRAN (R 4.1.0)
P prettyunits 1.1.1 2020-01-24 [?] CRAN (R 4.1.0)
P processx 3.5.2 2021-04-30 [?] CRAN (R 4.1.0)
P proxy 0.4-26 2021-06-07 [?] CRAN (R 4.1.0)
P ps 1.6.0 2021-02-28 [?] CRAN (R 4.1.0)
P purrr 0.3.4 2020-04-17 [?] CRAN (R 4.1.0)
P R6 2.5.1 2021-08-19 [?] CRAN (R 4.1.0)
P Rcpp 1.0.8.2 2022-03-11 [?] CRAN (R 4.1.2)
P remotes 2.4.2 2021-11-30 [?] CRAN (R 4.1.0)
P renv * 0.15.4 2022-03-03 [?] CRAN (R 4.1.2)
P rgdal 1.5-28 2021-12-15 [?] CRAN (R 4.1.0)
rlang 0.4.11 2021-04-30 [2] CRAN (R 4.1.0)
VP rmarkdown 2.13 2021-05-07 [?] CRAN (R 4.1.0) (on disk 2.8)
P rprojroot 2.0.2 2020-11-15 [?] CRAN (R 4.1.0)
P rstudioapi 0.13 2020-11-12 [?] CRAN (R 4.1.0)
P s2 1.0.7 2021-09-28 [?] CRAN (R 4.1.0)
P sessioninfo 1.2.2 2021-12-06 [?] CRAN (R 4.1.0)
P sf 1.0-7 2022-03-07 [?] CRAN (R 4.1.2)
P sp 1.4-6 2021-11-14 [?] CRAN (R 4.1.0)
stringi 1.6.2 2021-05-17 [2] CRAN (R 4.1.0)
P testthat 3.1.2 2022-01-20 [?] CRAN (R 4.1.2)
P tibble 3.1.6 2021-11-07 [?] CRAN (R 4.1.0)
P units 0.8-0 2022-02-05 [?] CRAN (R 4.1.2)
P usethis 2.1.5 2021-12-09 [?] CRAN (R 4.1.0)
P utf8 1.2.2 2021-07-24 [?] CRAN (R 4.1.0)
P vctrs 0.3.8 2021-04-29 [?] CRAN (R 4.1.0)
P withr 2.5.0 2022-03-03 [?] CRAN (R 4.1.2)
P wk 0.6.0 2022-01-03 [?] CRAN (R 4.1.2)
VP xfun 0.30 2021-05-15 [?] CRAN (R 4.1.0) (on disk 0.23)
yaml 2.2.1 2020-02-01 [2] CRAN (R 4.1.0)
P zip 2.2.0 2021-05-31 [?] CRAN (R 4.1.0)

[1] /Users/gwarnes/MyDrive/src/ukraine-study-map/renv/library/R-4.1/x86_64-apple-darwin17.0
[2] /Library/Frameworks/R.framework/Versions/4.1/Resources/library

V ── Loaded and on-disk version mismatch.
P ── Loaded and on-disk path mismatch.

────────────────────────────────────────────────────────────────────────────

</details>
@agila5 agila5 closed this as completed in 12f7e91 Mar 16, 2022
@agila5
Copy link
Contributor

agila5 commented Mar 16, 2022

Dear @gwarnes-mdsol, thanks for reasing this issue. I think that the problem was fixed in the development version of the package:

# packages
library(osmextract)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright.
#> Check the package website, https://docs.ropensci.org/osmextract/, for more details.

# output from osmextract
keys <- oe_get_keys('belarus', 'points')
health_keys <- grep('health|hosp', keys, ignore.case = TRUE, value = TRUE)
health_keys
#>  [1] "healthcare"                    "healthcare:speciality"        
#>  [3] "health_facility:type"          "health"                       
#>  [5] "was:healthcare"                "construction:healthcare"      
#>  [7] "health_specialty:dentistry"    "health_specialty:obstetrics"  
#>  [9] "health_specialty:traumatology" "hospital"                     
#> [11] "planned:healthcare"
vals <- oe_get_keys('belarus', 'points', which_keys = health_keys, values = TRUE)
vals
#> Found 11 unique keys, printed in ascending order of % NA values. The first 10 keys are: 
#> healthcare (99% NAs) = {#pharmacy = 1123; #dentist = 188; #clinic = 151; #doc...}
#> healthcare:speciality (99% NAs) = {#laboratory = 21; #general = 14; #dentist ...}
#> health_facility:type (99% NAs) = {#clinic = 2; #department = 2; #laboratory =...}
#> health (99% NAs) = {#doctor = 6}
#> was:healthcare (99% NAs) = {#pharmacy = 4}
#> construction:healthcare (99% NAs) = {#clinic = 2; #pharmacy = 1}
#> health_specialty:dentistry (99% NAs) = {#yes = 1}
#> health_specialty:obstetrics (99% NAs) = {#main = 1}
#> health_specialty:traumatology (99% NAs) = {#main = 1}
#> hospital (99% NAs) = {#information = 1}
#> [Truncated output...]
str(unclass(vals))
#> List of 11
#>  $ healthcare                   : chr [1:1780] "clinic" "clinic" "pharmacy" "hospital" ...
#>  $ healthcare:speciality        : chr [1:167] "paediatrics;psychiatry" "narcology" "psychiatry" "child_psychiatry" ...
#>  $ health_facility:type         : chr [1:8] "department" "clinic" "clinic" "laboratory" ...
#>  $ health                       : chr [1:6] "doctor" "doctor" "doctor" "doctor" ...
#>  $ was:healthcare               : chr [1:4] "pharmacy" "pharmacy" "pharmacy" "pharmacy"
#>  $ construction:healthcare      : chr [1:3] "clinic" "clinic" "pharmacy"
#>  $ health_specialty:dentistry   : chr "yes"
#>  $ health_specialty:obstetrics  : chr "main"
#>  $ health_specialty:traumatology: chr "main"
#>  $ hospital                     : chr "information"
#>  $ planned:healthcare           : chr "pharmacy"
#>  - attr(*, "nfeatures_OSM")= int 876595

Created on 2022-03-16 by the reprex package (v2.0.1)

If you need to install the development version, please run remotes::install_github("ropensci/osmextract").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants