diff --git a/DESCRIPTION b/DESCRIPTION index a4e7dbf1..79fa4138 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Type: Package Package: pxweb Title: R Interface to PXWEB APIs Version: 0.16.3 -Date: 2024-01-14 +Date: 2024-01-13 Authors@R: c( person("Mans", "Magnusson", , "mons.magnusson@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-0296-2719")), diff --git a/NAMESPACE b/NAMESPACE index 6ac471ca..7fc69632 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -15,6 +15,10 @@ S3method(print,pxweb_levels) S3method(print,pxweb_metadata) S3method(print,pxweb_query) S3method(pxweb_api_catalogue_entry,list) +S3method(pxweb_as_data_frame,pxweb_data) +S3method(pxweb_as_data_frame,pxweb_data_comment) +S3method(pxweb_as_data_frame,pxweb_data_comments) +S3method(pxweb_as_data_frame,pxweb_levels) S3method(pxweb_data_comments,pxweb_data) S3method(pxweb_query,character) S3method(pxweb_query,json) @@ -38,6 +42,7 @@ export(pxweb_advanced_get) export(pxweb_api) export(pxweb_api_catalogue) export(pxweb_api_catalogue_path) +export(pxweb_as_data_frame) export(pxweb_cite) export(pxweb_data_comments) export(pxweb_get) diff --git a/R/pxweb_as_data_frame.R b/R/pxweb_as_data_frame.R index ff84871a..f1d0172a 100644 --- a/R/pxweb_as_data_frame.R +++ b/R/pxweb_as_data_frame.R @@ -10,7 +10,7 @@ #' #' @seealso \code{\link[base]{as.data.frame}}. #' -#' @keywords internal +#' @export pxweb_as_data_frame <- function(x, row.names = NULL, optional = FALSE, ..., stringsAsFactors = FALSE, column.name.type = "text", variable.value.type = "text") { checkmate::assert_choice(column.name.type, c("code", "text")) checkmate::assert_choice(column.name.type, c("code", "text")) @@ -18,7 +18,7 @@ pxweb_as_data_frame <- function(x, row.names = NULL, optional = FALSE, ..., stri } #' @rdname pxweb_as_data_frame -#' @keywords internal +#' @export pxweb_as_data_frame.pxweb_data <- function(x, row.names = NULL, optional = FALSE, ..., stringsAsFactors = FALSE, column.name.type = "text", variable.value.type = "text") { pxdims <- pxweb_data_dim(x) checkmate::assert_character(row.names, len = pxdims[1], null.ok = TRUE) @@ -45,7 +45,7 @@ pxweb_as_data_frame.pxweb_data <- function(x, row.names = NULL, optional = FALSE } #' @rdname pxweb_as_data_frame -#' @keywords internal +#' @export pxweb_as_data_frame.pxweb_data_comments <- function(x, optional = FALSE, ..., stringsAsFactors = FALSE) { checkmate::assert_flag(optional) checkmate::assert_flag(stringsAsFactors) @@ -72,7 +72,7 @@ pxweb_as_data_frame.pxweb_data_comments <- function(x, optional = FALSE, ..., st } #' @rdname pxweb_as_data_frame -#' @keywords internal +#' @export pxweb_as_data_frame.pxweb_data_comment <- function(x, optional = FALSE, ..., stringsAsFactors = FALSE) { checkmate::assert_flag(optional) checkmate::assert_flag(stringsAsFactors) @@ -92,7 +92,7 @@ pxweb_as_data_frame.pxweb_data_comment <- function(x, optional = FALSE, ..., str #' @rdname pxweb_as_data_frame -#' @keywords internal +#' @export pxweb_as_data_frame.pxweb_levels <- function(x, optional = FALSE, ..., stringsAsFactors = FALSE) { checkmate::assert_flag(optional) checkmate::assert_flag(stringsAsFactors) diff --git a/inst/CITATION b/inst/CITATION index 7409cef9..3c37c3ba 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -1,8 +1,8 @@ citHeader("Kindly cite the pxweb R package as follows:") -citEntry(entry="misc", +bibentry(bibtype="misc", title = "pxweb: R tools for PX-WEB API", - author = personList( + author = c( person(given = "Mans", family= "Magnusson", email = "mons.magnusson@gmail.com"), person(given = "Markus", family= "Kainu"), person(given = "Janne", family= "Huovari"), diff --git a/vignettes/pxweb.Rmd b/vignettes/pxweb.Rmd index 42b8e42f..56af0781 100644 --- a/vignettes/pxweb.Rmd +++ b/vignettes/pxweb.Rmd @@ -13,7 +13,7 @@ vignette: > This R package provides tools to access [PX-WEB -API](https://pxnet2.stat.fi/API-description_SCB.pdf). Your +API](https://www.scb.se/en/services/open-data-api/api-for-the-statistical-database/). Your [contributions](https://ropengov.org/community/) and [bug reports and other feedback](https://github.com/ropengov/pxweb) are welcome! @@ -30,8 +30,8 @@ The `pxweb` R package connects any PXWEB API to R and facilitates the access, us [A number of organizations](https://www.scb.se/en/services/statistical-programs-for-px-files/px-web/pxweb-examples/) use PXWEB to distribute hierarchical data. You can browse the available data sets at: - * [Statistics Sweden](http://www.statistikdatabasen.scb.se/pxweb/en/ssd/) with [API Description](https://pxnet2.stat.fi/API-description_SCB.pdf) - * [Statistics Finland](https://tilastokeskus.fi/til/aihealuejako.html) [StatFi API Description](https://pxnet2.stat.fi/api1.html) + * [Statistics Sweden](http://www.statistikdatabasen.scb.se/pxweb/en/ssd/) with [API Description](https://www.scb.se/en/services/open-data-api/api-for-the-statistical-database/) + * [Statistics Finland](https://tilastokeskus.fi/til/aihealuejako.html) [StatFi API Description](https://statfin.stat.fi/api1.html) * [Other organizations using PX-WEB](https://www.scb.se/en/services/statistical-programs-for-px-files/px-web/pxweb-examples/) ### About PXWEB APIs diff --git a/vignettes/pxweb.html b/vignettes/pxweb.html index b4a5a5e2..10a3fc78 100644 --- a/vignettes/pxweb.html +++ b/vignettes/pxweb.html @@ -240,7 +240,7 @@ background-color: #f7f7f7; border-radius: 3px; color: #333; -white-space: pre-wrap; +white-space: pre-wrap; } pre { border-radius: 3px; @@ -308,18 +308,18 @@ a[href^="https:"] { text-decoration: underline; } -code > span.kw { color: #555; font-weight: bold; } -code > span.dt { color: #902000; } -code > span.dv { color: #40a070; } -code > span.bn { color: #d14; } -code > span.fl { color: #d14; } -code > span.ch { color: #d14; } -code > span.st { color: #d14; } -code > span.co { color: #888888; font-style: italic; } -code > span.ot { color: #007020; } -code > span.al { color: #ff0000; font-weight: bold; } -code > span.fu { color: #900; font-weight: bold; } -code > span.er { color: #a61717; background-color: #e3d2d2; } +code > span.kw { color: #555; font-weight: bold; } +code > span.dt { color: #902000; } +code > span.dv { color: #40a070; } +code > span.bn { color: #d14; } +code > span.fl { color: #d14; } +code > span.ch { color: #d14; } +code > span.st { color: #d14; } +code > span.co { color: #888888; font-style: italic; } +code > span.ot { color: #007020; } +code > span.al { color: #ff0000; font-weight: bold; } +code > span.fu { color: #900; font-weight: bold; } +code > span.er { color: #a61717; background-color: #e3d2d2; } @@ -369,7 +369,7 @@
This R package provides tools to access PX-WEB API. +
This R package provides tools to access PX-WEB API. Your contributions and bug reports and other feedback are welcome!
We can find more information on the PX-Web/PC-Axis API here.
@@ -389,10 +389,10 @@## PXWEB METADATA
-## Population by region, marital status, age, sex, observations and year
+## Population by region, marital status, age, sex, observations and year
## variables:
## [[1]] Region: region
## [[2]] Civilstand: marital status
@@ -840,7 +840,7 @@ Downloading data
as.matrix
.
<- as.matrix(pxd, column.name.type = "code", variable.value.type = "code")
pxmat head(pxmat)
-## Civilstand Kon Tid BE0101N1
+## Civilstand Kon Tid BE0101N1
## [1,] "OG" "1" "2015" "2762601"
## [2,] "OG" "1" "2016" "2820248"
## [3,] "OG" "1" "2017" "2870477"
@@ -868,14 +868,14 @@ Citation
pxweb_data
object using the pxweb_cite()
function. For full reproducibility, please also cite the package.
pxweb_cite(pxd)
-##
+##
## Statistics Sweden (2022). "Population by region, marital status, age,
## sex, observations and year." [Data accessed 2022-10-31 10:01:52 using
## pxweb R package 0.16.2],
## <https://api.scb.se/OV0104/v1/doris/en/ssd/BE/BE0101/BE0101A/BefolkningNy>.
-##
+##
## A BibTeX entry for LaTeX users is
-##
+##
## @Misc{,
## title = {Population by region, marital status, age, sex, observations and year},
## author = {{Statistics Sweden}},
@@ -885,18 +885,18 @@ Citation
## url = {https://api.scb.se/OV0104/v1/doris/en/ssd/BE/BE0101/BE0101A/BefolkningNy},
## note = {[Data accessed 2022-10-31 10:01:52 using pxweb R package 0.16.2]},
## }
-##
-##
-##
-##
+##
+##
+##
+##
## Kindly cite the pxweb R package as follows:
-##
+##
## Mans Magnusson, Markus Kainu, Janne Huovari, and Leo Lahti
## (rOpenGov). pxweb: R tools for PXWEB API. URL:
## http://github.com/ropengov/pxweb
-##
+##
## A BibTeX entry for LaTeX users is
-##
+##
## @Misc{,
## title = {pxweb: R tools for PX-WEB API},
## author = {Mans Magnusson and Markus Kainu and Janne Huovari and Leo Lahti},
@@ -921,34 +921,34 @@ Session info
## R version 4.2.1 (2022-06-23)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Big Sur ... 10.16
-##
+##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
-##
+##
## locale:
## [1] C/sv_SE.UTF-8/sv_SE.UTF-8/C/sv_SE.UTF-8/sv_SE.UTF-8
-##
+##
## attached base packages:
-## [1] stats graphics grDevices utils datasets methods base
-##
+## [1] stats graphics grDevices utils datasets methods base
+##
## other attached packages:
## [1] pxweb_0.16.2
-##
+##
## loaded via a namespace (and not attached):
-## [1] jquerylib_0.1.4 bslib_0.3.1 pillar_1.7.0 compiler_4.2.1
-## [5] prettyunits_1.1.1 remotes_2.4.2 tools_4.2.1 digest_0.6.29
-## [9] pkgbuild_1.3.1 pkgload_1.3.0 evaluate_0.15 jsonlite_1.8.0
-## [13] memoise_2.0.1 lifecycle_1.0.1 tibble_3.1.7 checkmate_2.1.0
-## [17] pkgconfig_2.0.3 rlang_1.0.3 cli_3.3.0 rstudioapi_0.13
-## [21] curl_4.3.2 yaml_2.3.5 xfun_0.31 fastmap_1.1.0
-## [25] httr_1.4.3 withr_2.5.0 stringr_1.4.0 roxygen2_7.2.0
-## [29] knitr_1.39 xml2_1.3.3 sass_0.4.1 desc_1.4.1
-## [33] fs_1.5.2 vctrs_0.4.1 devtools_2.4.3 rprojroot_2.0.3
-## [37] glue_1.6.2 R6_2.5.1 processx_3.6.1 fansi_1.0.3
-## [41] rmarkdown_2.14 sessioninfo_1.2.2 callr_3.7.0 purrr_0.3.4
-## [45] magrittr_2.0.3 htmltools_0.5.2 backports_1.4.1 ps_1.7.1
-## [49] ellipsis_0.3.2 usethis_2.1.6 utf8_1.2.2 stringi_1.7.6
+## [1] jquerylib_0.1.4 bslib_0.3.1 pillar_1.7.0 compiler_4.2.1
+## [5] prettyunits_1.1.1 remotes_2.4.2 tools_4.2.1 digest_0.6.29
+## [9] pkgbuild_1.3.1 pkgload_1.3.0 evaluate_0.15 jsonlite_1.8.0
+## [13] memoise_2.0.1 lifecycle_1.0.1 tibble_3.1.7 checkmate_2.1.0
+## [17] pkgconfig_2.0.3 rlang_1.0.3 cli_3.3.0 rstudioapi_0.13
+## [21] curl_4.3.2 yaml_2.3.5 xfun_0.31 fastmap_1.1.0
+## [25] httr_1.4.3 withr_2.5.0 stringr_1.4.0 roxygen2_7.2.0
+## [29] knitr_1.39 xml2_1.3.3 sass_0.4.1 desc_1.4.1
+## [33] fs_1.5.2 vctrs_0.4.1 devtools_2.4.3 rprojroot_2.0.3
+## [37] glue_1.6.2 R6_2.5.1 processx_3.6.1 fansi_1.0.3
+## [41] rmarkdown_2.14 sessioninfo_1.2.2 callr_3.7.0 purrr_0.3.4
+## [45] magrittr_2.0.3 htmltools_0.5.2 backports_1.4.1 ps_1.7.1
+## [49] ellipsis_0.3.2 usethis_2.1.6 utf8_1.2.2 stringi_1.7.6
## [53] cachem_1.0.6 crayon_1.5.1