rOpenGov / pxweb

R tools to access PX-WEB API
http://ropengov.github.io/pxweb
Other
69 stars 31 forks source link

Can't acces norwegian data #175

Closed Mankargren closed 5 years ago

Mankargren commented 5 years ago

Hi,

I can't access data from ssb (Norway). I get all the way down to node 3, but an error message at node 4.

I get the following error message: "Error in $<-.data.frame(*tmp*, "text", value = character(0)) : replacement has 0 rows, data has 1"

Does it point to the correct URL?

I run on:

sessionInfo() R version 3.5.0 (2018-04-23) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale: [1] LC_COLLATE=Swedish_Sweden.1252 LC_CTYPE=Swedish_Sweden.1252 LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C LC_TIME=Swedish_Sweden.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] pxweb_0.6.37 jsonlite_1.5 httr_1.3.1

loaded via a namespace (and not attached): [1] compiler_3.5.0 plyr_1.8.4 magrittr_1.5 R6_2.2.2 tools_3.5.0 yaml_2.1.19 Rcpp_0.12.16 RJSONIO_1.3-0 stringi_1.1.7 data.table_1.11.4 [11] stringr_1.3.0

packageVersion("pxweb") [1] ‘0.6.37’

Kindly, Matilda

MansMeg commented 5 years ago

Thanks! Do you have a reproducible example?

MansMeg commented 5 years ago

Also, have you tried the new pxweb version? 0.9.1 may solve your problem.

Mankargren commented 5 years ago

It does not work with that version either. I use the interactive_pxweb() function, and I don't now how to extract code for an example?

However, I make the following choices (in version 0.9.1): 16 (ssb) 1 (en) 3 (population) 5 ( population count) 1 (population)

Can I pull the code generated from the interactive function even though I don't make it "to the end" of the list of choices? It works fine for other countries api:s.

MansMeg commented 5 years ago

I have not tried it yet, but my gut reaction is that it is probably a bug in the SSB API. I’ll look at it asap.

Mankargren commented 5 years ago

Thank you! I seem to have the same problem with Greenland Statistics (no 13 in version 0.9.1). Kindly, Matilda

MansMeg commented 5 years ago

Hmm.

I get it to work:

R PXWEB: Content of 'data.ssb.no' at '/api/v0/en/table/be/be05/folkemengde'

[ 1 ] : 07459: Population, by sex and one-year age groups (M) 1986 - 2018 [ 2 ] : 06913: Population 1 January and population changes during the calendar year (M) 1951 - 2018 [ 3 ] : 03027: Population, by marital status (M) 1986 - 2018 [ 4 ] : 03031: Population, by sex, age and marital status (C) 1986 - 2018

[ 20 ] : 04362: Population, by sex and age (BU) 2001 - 2018 [ 21 ] : 05231: Estimated population per December 31st, and population growth during the year (M) 2009 - 2018 [ 22 ] : 03037: Mean population, by ten year age groups, sex and marital status (C) 1987 - 2017 [ 23 ] : 07236: Mean population and population changes per 1 000 population 1997K4 - 2018K3

Enter your choice: ('esc' = Quit, 'b' = Back, 'a' = Show all, 'i' = Show id)

MansMeg commented 5 years ago

It seems like you are on a windows machine. Those can have issues: Have you tried: Sys.setlocale(locale="UTF-8")

See installation issues here: https://github.com/rOpenGov/pxweb/blob/master/vignettes/pxweb.md

Mankargren commented 5 years ago

That does not seem to work. It renders the following warning:

Warning message: In Sys.setlocale(locale = "UTF-8") : OS reports request to set locale to "UTF-8" cannot be honored

It seems like a problem more people have had difficulties solving. Unfortunately.

MansMeg commented 5 years ago

I guess it is the encoding somehow on a windows machine. @antagomir or maybe @jhuovari may have some idea how this can be solved, I think they have encountered similar problems before.

MansMeg commented 5 years ago

A workaround can be to just naviaget through:

p2 <-  pxweb_get(url = 'http://data.ssb.no/api/v0/en/table/be/be05/folkemengde')
p2

Find what part you want and start interactive from there:

res <-  pxweb_interactive('http://data.ssb.no/api/v0/en/table/be/be05/folkemengde/NY3026')

This worked for me, but may not work for you.

Mankargren commented 5 years ago

Thank you so much, that works for me!

jhuovari commented 5 years ago

I did get an error at the first time I tried, but not any more. Temporary problem at SSB?

MansMeg commented 5 years ago

Maybe? @Mankargren does it work for you now?

MansMeg commented 5 years ago

I close this issue now. We can reopen it if anyone else has the same problem. My guess is still that is a Windows encoding error.