rOpenGov / pxweb

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

Statistics Estonia - include formats “sdmx” or “px” #242

Closed mapdek closed 2 years ago

mapdek commented 2 years ago

Dear People,

Would it be possible to include the formats 'sdmx' and 'px' when doing an API request from Statistics Estonia?

Statistics Estonia only seems to make available all decimals in data requests when these 2 data formats are extracted from therir API, whereas only 1 decimal is obtained while using JSON formats.

Please let me know if you need more detailed information on this.

Kind regards, Marnix

load library pxweb

library(pxweb)

start the interactive manu from PX library to create string

d <- pxweb_interactive()

PXWEB query

pxweb_query_list <- 
  list("Aasta"=c("*"),
       "Kasutamine/ Ressursid"=c("*"),
       "Näitaja"=c("*"),
       "Sektor"=c("*"))

Download data

px_data <- pxweb_get(url = "[https://andmed.stat.ee/api/v1/en/stat/majandus/rahvamajanduse-arvepidamine/kontod/mittefinantskonto/RAM001.PX](https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fandmed.stat.ee%2Fapi%2Fv1%2Fen%2Fstat%2Fmajandus%2Frahvamajanduse-arvepidamine%2Fkontod%2Fmittefinantskonto%2FRAM001.PX&data=05%7C01%7CMarnix.DEK%40oecd.org%7C0bfd101e3d754455d46e08da373a872b%7Cac41c7d41f61460db0f4fc925a2b471c%7C0%7C1%7C637883021777525588%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=y7PL8FpkhLRQtF5lj3fTVt53zhbWE%2BgSzuStEKmZ6nA%3D&reserved=0)",
            query = pxweb_query_list)

Convert to data.frame

px_data_frame <- as.data.frame(px_data, column.name.type = "text", variable.value.type = "text")

whereas from the online data, one can extract all decimals:

[https://andmed.stat.ee/en/stat/majandus__rahvamajanduse-arvepidamine__kontod__mittefinantskonto/RAM001]

image

MansMeg commented 2 years ago

In the new release (0.15.1), you can now download px files and sdmx files. Its on its way to CRAN.