pxweb_get: Do a GET call to PXWEB API

Description Usage Arguments Examples

View source: R/pxweb_get.R

Description

Do a GET call to PXWEB API

Usage

1
pxweb_get(url, query = NULL, verbose = TRUE)

Arguments

url

a pxweb object or url that can be coherced to a pxweb object.

query

a json string, json file or list object that can be coherced to a pxweb_query object.

verbose

should large queries print out progress.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
## Not run: 
url <- "http://api.scb.se/OV0104/v1/doris/sv/ssd/BE/BE0101/BE0101A/BefolkningNy"
px_meta_data <- pxweb_get(url)

url <- "http://api.scb.se/OV0104/v1/doris/sv/ssd/BE/BE0101"
px_levels <- pxweb_get(url)

url <- "http://api.scb.se/OV0104/v1/doris/sv"
px_levels <- pxweb_get(url)

url <- "http://api.scb.se/OV0104/v1/doris/sv/ssd/BE/BE0101/BE0101A/BefolkningNy"
query <- file.path(system.file(package = "pxweb"),
                   "extdata", "examples", "json_query_example.json")
px_data <- pxweb_get(url = url, query = query)

# Convert to data.frame
as.data.frame(px_data, column.name.type = "text", variable.value.type = "text")

# Get raw data
as.matrix(px_data, column.name.type = "code", variable.value.type = "code")

# Get data comments
pxweb_data_comments(px_data)

# Get jsonstat data
jstat <- query <- file.path(system.file(package = "pxweb"),
                            "extdata", "examples", "json-stat_query_example.json")
jstat_data <- pxweb_get(url = url, query = query)

# Get very large datasets (multiple downloads needed)
big_query <- file.path(system.file(package = "pxweb"),
                       "extdata", "examples", "json_big_query_example.json")
px_data <- pxweb_get(url = url, query = big_query)

## End(Not run)

pxweb documentation built on Oct. 10, 2021, 1:06 a.m.