forked from rOpenGov/sotkanet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
executable file
·153 lines (117 loc) · 6.79 KB
/
README.Rmd
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "90%"
)
```
# sotkanet: Tools for accessing open data on welfare and health in Finland <a href="https://ropengov.github.io/sotkanet/"><img src="man/figures/logo.png" align="right" height="139"/></a>
<!-- badges: start -->
[![rOG-badge](https://ropengov.github.io/rogtemplate/reference/figures/ropengov-badge.svg)](http://ropengov.org/)
[![R build status](https://github.com/rOpenGov/sotkanet/workflows/R-CMD-check/badge.svg)](https://github.com/rOpenGov/sotkanet/actions)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/sotkanet)](https://cran.r-project.org/package=sotkanet)
[![r-universe](https://ropengov.r-universe.dev/badges/sotkanet)](https://ropengov.r-universe.dev/)
[![Downloads total](http://cranlogs.r-pkg.org/badges/grand-total/sotkanet)](https://cran.r-project.org/package=sotkanet)
[![Downloads monthly](https://cranlogs.r-pkg.org/badges/sotkanet)](https://www.r-pkg.org/pkg/sotkanet)
[![Watch on GitHub][github-watch-badge]][github-watch]
[![Star on GitHub][github-star-badge]][github-star]
[![Follow on Twitter](https://img.shields.io/twitter/follow/ropengov.svg?style=social)](https://twitter.com/intent/follow?screen_name=ropengov)
[![Codecov test coverage](https://codecov.io/gh/rOpenGov/sotkanet/branch/master/graph/badge.svg)](https://app.codecov.io/gh/rOpenGov/sotkanet?branch=master)
<!-- badges: end -->
R package to access and manipulate data from the Sotkanet demographics indicator database. The [Sotkanet data portal] provides over 2000 demographic indicators across Finland and Europe, and is maintained by the [National Institute for Health and Welfare (THL)]. For more information, see [data description].
### Installation
You can install the stable release version from CRAN:
```{r install, eval=FALSE}
install.packages("sotkanet")
```
Alternatively, you can install the development version of sotkanet package from GitHub with:
```{r_github, eval = FALSE}
# install.packages("remotes")
remotes::install_github("rOpenGov/sotkanet")
```
Development version can be also installed using the
[r-universe](https://ropengov.r-universe.dev):
```{r, eval=FALSE}
# Enable this universe
options(repos = c(
ropengov = "https://ropengov.r-universe.dev",
CRAN = "https://cloud.r-project.org"
))
install.packages("sotkanet")
```
### Using the package
Load the package in R:
```{r example_load, eval=TRUE, message=FALSE}
library(sotkanet)
```
List available indicators in the Sotkanet data portal:
```{r sotkanetIndicators, warning=FALSE, message=FALSE, eval=TRUE}
# Pre-defined list of indicators to save bandwidth
sotkanet.indicators <- SotkanetIndicators(c(4,5,6,7,46,74))
head(sotkanet.indicators$indicator.title.fi)
```
Here is an example of data retrieval and visualization, using indicator describing private dental care use among 0-17 years old in 2015-2020.
```{r sotkanet_example, eval=TRUE}
library(ggplot2)
library(ggrepel)
hammashoito <- GetDataSotkanet(indicators = 1075, years = 2015:2020, genders = "total", region.category = "MAAKUNTA")
# Indicator title tells what this indicator is about
unique(hammashoito$indicator.title.fi)
# Some data has to be retrieved separately
hammashoito_metadata <- SotkanetIndicatorMetadata(id = 1075)
plot_caption <- paste0("Lähde: https://sotkanet.fi / ", hammashoito_metadata$organization$title$fi, "\n",
"Datan päiväys ", hammashoito_metadata$`data-updated`)
plot <- ggplot(hammashoito, aes(x=year, y=primary.value, group=region.title.fi))+
geom_line(aes(color=region.title.fi)) +
geom_point(aes(color=region.title.fi))
plot + labs(title = "Yksityisen hammashuollon käynnit 2015-2020",
subtitle = "0 - 17-vuotiailla / 1 000 vastaavanikäistä",
x = "Vuosi",
y = "Käyntien lkm",
caption = plot_caption,
color = "Maakunta") +
geom_text_repel(
aes(color = region.title.fi, label = ifelse(year == 2020, region.title.fi, NA_character_)),
xlim = c(2021, 2023),
direction = "both",
hjust = 0,
segment.size = .7,
segment.alpha = .5,
segment.linetype = "dotted",
box.padding = .4,
segment.curvature = -0.1,
segment.ncp = 3,
segment.angle = 20) +
theme(legend.position = "none",
panel.background = element_rect(fill = "linen")) +
scale_x_continuous(
expand = c(0, 0),
limits = c(2015, 2022),
breaks = seq(2015, 2020))
```
For more in-depth examples, see the package vignette or online [tutorial page](http://ropengov.github.io/sotkanet/articles/tutorial.html).
### Contributing
* [Submit suggestions and bug reports](https://github.com/ropengov/sotkanet/issues) (provide the output of `sessionInfo()` and `packageVersion("sotkanet")` and preferably provide a [reproducible example](http://adv-r.had.co.nz/Reproducibility.html))
* [Send a pull request](https://github.com/ropengov/sotkanet/pulls)
* [Star us on the Github page](https://github.com/ropengov/sotkanet/)
* [See our website](http://ropengov.org/community/) for additional contact information
### Acknowledgements
**Kindly cite this work** as follows: [Leo Lahti](https://github.com/antagomir), Einari Happonen, Juuso Parkkinen, Joona Lehtomaki, Vesa Saaristo and Pyry Kantanen (rOpenGov 2022). sotkanet: Sotkanet Open Data Access and Analysis. R package version 0.9.77. URL: https://github.com/rOpenGov/sotkanet
We are grateful to all [contributors](https://github.com/ropengov/sotkanet/graphs/contributors), and for the [Sotkanet](https://sotkanet.fi/sotkanet/en/index?) Statistics and Indicator Bank! This project is part of [rOpenGov](http://ropengov.org).
### Disclaimer
This package is in no way officially related to or endorsed by The Finnish Institute for Health and Welfare (Terveyden ja hyvinvoinnin laitos, THL).
For information about THL's open data license and limitation of liability, please see their website:
* In English: [THL's open data license and limitation of liability](https://yhteistyotilat.fi/wiki08/display/THLKA/THL%27s+open+data+license+and+limitation+of+liability)
* In Finnish: [THL:n avoimen datan lisenssi ja vastuuvapauslauseke](https://yhteistyotilat.fi/wiki08/display/THLKA/THL%3An+avoimen+datan+lisenssi+ja+vastuuvapauslauseke)
[Sotkanet data portal]: https://sotkanet.fi/sotkanet/fi/index
[National Institute for Health and Welfare (THL)]: https://thl.fi/fi/
[data description]: https://sotkanet.fi/sotkanet/en/data
[github-watch-badge]: https://img.shields.io/github/watchers/ropengov/sotkanet.svg?style=social
[github-watch]: https://github.com/ropengov/sotkanet/watchers
[github-star-badge]: https://img.shields.io/github/stars/ropengov/sotkanet.svg?style=social
[github-star]: https://github.com/ropengov/sotkanet/stargazers