File: SCB.Rd

package info (click to toggle)
r-cran-htmltable 2.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,600 kB
  • sloc: javascript: 6,797; makefile: 2
file content (51 lines) | stat: -rw-r--r-- 1,508 bytes parent folder | download
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data-SCB.R
\docType{data}
\name{SCB}
\alias{SCB}
\title{Average age in Sweden}
\description{
For the vignettes there is a dataset downloaded by using the
\code{get_pxweb_data()} call. The data is from
SCB (\href{https://www.scb.se//}{Statistics Sweden}) and downloaded
using the \href{https://github.com/rOpenGov/pxweb}{pxweb package}:
}
\examples{
\dontrun{
# The data was generated through downloading via the API
library(pxweb)

# Get the last 15 years of data (the data always lags 1 year)
current_year <- as.integer(format(Sys.Date(), "\%Y")) -1
SCB <- get_pxweb_data(
  url = "http://api.scb.se/OV0104/v1/doris/en/ssd/BE/BE0101/BE0101B/BefolkningMedelAlder",
  dims = list(Region = c('00', '01', '03', '25'),
              Kon = c('1', '2'),
              ContentsCode = c('BE0101G9'),
              Tid = (current_year-14):current_year),
  clean = TRUE)

# Some cleaning was needed before use
SCB$region <- factor(substring(as.character(SCB$region), 4))
Swe_ltrs <- c("å" = "&aring;",
              "Å" = "&Aring;",
              "ä" = "&auml;",
              "Ä" = "&Auml;",
              "ö" = "&ouml;",
              "Ö" = "&Ouml;")
for (i in 1:length(Swe_ltrs)){
  levels(SCB$region) <- gsub(names(Swe_ltrs)[i],
              Swe_ltrs[i],
              levels(SCB$region))
}

save(SCB, file = "data/SCB.rda")
}
}
\references{
\url{https://www.scb.se/}
}
\author{
Max Gordon \email{max@gforge.se}
}
\keyword{data}