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

get_dataset returns error message #28

Open
Lit-Fam opened this issue Oct 12, 2023 · 1 comment
Open

get_dataset returns error message #28

Lit-Fam opened this issue Oct 12, 2023 · 1 comment

Comments

@Lit-Fam
Copy link

Lit-Fam commented Oct 12, 2023

Dear Eric,

this package could be incredibly helpful for me, thanks for publishing it.

Unfortunately, the code at the bottom of my post returns an error when I try to run it. I'm using R-4.1.3 in RStudio. get_datasets() works fine, but get_dataset() returns the following error message:

> df <- get_dataset("PATS_REGION", filter = "PCT_A.INVENTORS.BEL+BE10.TOTAL+BIOTECH", pre_formatted = TRUE)
Error in download.file(path, destfile, method, quiet, mode, ...) : 
  cannot open URL 'https://stats.oecd.org/restsdmx/sdmx.ashx/GetData/PATS_REGION/PCT_A.INVENTORS.BEL+BE10.TOTAL+BIOTECH/all'
In addition: Warning message:
In download.file(path, destfile, method, quiet, mode, ...) :
  URL 'https://stats.oecd.org/restsdmx/sdmx.ashx/GetData/PATS_REGION/PCT_A.INVENTORS.BEL+BE10.TOTAL+BIOTECH/all': status was 'Couldn't connect to server'

Here's the script I tried to run:

library(OECD)
library(httr)
httr::set_config(httr::use_proxy("192.168.78.10", port = 8080, auth = "basic"))
datasets <- get_datasets()
df <- get_dataset("PATS_REGION", filter = "PCT_A.INVENTORS.BEL+BE10.TOTAL+BIOTECH", pre_formatted = TRUE)

Like I mentioned, get_dataset() returns the expected data frame. I suspect there may have been a change in the API?

@luifrancgom
Copy link

I think this project is not mantained anymore because I have a similar problem but I don't know how to build a package. Check the other issues and take into account that this repo contains the 0.24 version, #25 .If you want you can use the following code to extract the data:

library(readsdmx)
library(tibble)

data <- read_sdmx(path = "https://stats.oecd.org/restsdmx/sdmx.ashx/GetData/PATS_REGION/PCT_A.INVENTORS.BEL+BE10.TOTAL+BIOTECH/all")
data |> as_tibble()
#> # A tibble: 148 × 9
#>    KINDPATENT KINDREGION ObsValue POWERCODE REGIONS TECHNO TIME_FORMAT Time 
#>    <chr>      <chr>      <chr>    <chr>     <chr>   <chr>  <chr>       <chr>
#>  1 PCT_A      INVENTORS  1        0         BEL     TOTAL  P1Y         1977 
#>  2 PCT_A      INVENTORS  0        0         BEL     TOTAL  P1Y         1978 
#>  3 PCT_A      INVENTORS  1.5      0         BEL     TOTAL  P1Y         1979 
#>  4 PCT_A      INVENTORS  9.8667   0         BEL     TOTAL  P1Y         1980 
#>  5 PCT_A      INVENTORS  24.5     0         BEL     TOTAL  P1Y         1981 
#>  6 PCT_A      INVENTORS  27.8333  0         BEL     TOTAL  P1Y         1982 
#>  7 PCT_A      INVENTORS  23.8333  0         BEL     TOTAL  P1Y         1983 
#>  8 PCT_A      INVENTORS  29.5024  0         BEL     TOTAL  P1Y         1984 
#>  9 PCT_A      INVENTORS  41.25    0         BEL     TOTAL  P1Y         1985 
#> 10 PCT_A      INVENTORS  33.3     0         BEL     TOTAL  P1Y         1986 
#> # ℹ 138 more rows
#> # ℹ 1 more variable: UNIT <chr>

Created on 2023-12-06 with reprex v2.0.2

Also OCDE stat is changing the API and there is a new website, https://data-explorer.oecd.org/.

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