1
+
1
2
<!-- README.md is generated from README.Rmd. Please edit that file -->
2
3
3
4
# 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 >
7
8
[ ![ rOG-badge] ( https://ropengov.github.io/rogtemplate/reference/figures/ropengov-badge.svg )] ( https://ropengov.org/ )
8
9
[ ![ R build
9
10
status] ( https://github.com/rOpenGov/sotkanet/workflows/R-CMD-check/badge.svg )] ( https://github.com/rOpenGov/sotkanet/actions )
10
- [ ![ CRAN \_ Status \_ Badge ] ( http://www.r-pkg.org/badges/version/sotkanet )] ( https://cran.r-project.org/package=sotkanet )
11
+ [ ![ CRAN_Status_Badge ] ( http://www.r-pkg.org/badges/version/sotkanet )] ( https://cran.r-project.org/package=sotkanet )
11
12
[ ![ r-universe] ( https://ropengov.r-universe.dev/badges/sotkanet )] ( https://ropengov.r-universe.dev/ )
12
13
[ ![ Downloads
13
14
total] ( http://cranlogs.r-pkg.org/badges/grand-total/sotkanet )] ( https://cran.r-project.org/package=sotkanet )
@@ -35,90 +36,104 @@ description](https://sotkanet.fi/sotkanet/en/data).
35
36
36
37
You can install the stable release version from CRAN:
37
38
38
- install.packages("sotkanet")
39
+ ``` r
40
+ install.packages(" sotkanet" )
41
+ ```
39
42
40
43
Alternatively, you can install the development version of sotkanet
41
44
package from GitHub with:
42
45
43
- # install.packages("remotes")
44
- remotes::install_github("rOpenGov/sotkanet")
46
+ ``` r
47
+ # install.packages("remotes")
48
+ remotes :: install_github(" rOpenGov/sotkanet" )
49
+ ```
45
50
46
51
Development version can be also installed using the
47
52
[ r-universe] ( https://ropengov.r-universe.dev ) :
48
53
49
- # Enable this universe
50
- options(repos = c(
51
- ropengov = "https://ropengov.r-universe.dev",
52
- CRAN = "https://cloud.r-project.org"
53
- ))
54
- install.packages("sotkanet")
54
+ ``` r
55
+ # Enable this universe
56
+ options(repos = c(
57
+ ropengov = " https://ropengov.r-universe.dev" ,
58
+ CRAN = " https://cloud.r-project.org"
59
+ ))
60
+ install.packages(" sotkanet" )
61
+ ```
55
62
56
63
### Using the package
57
64
58
65
Load the package in R:
59
66
60
- library(sotkanet)
67
+ ``` r
68
+ library(sotkanet )
69
+ ```
61
70
62
71
List available indicators in the Sotkanet data portal:
63
72
64
- # Pre-defined list of indicators to save bandwidth
65
- sotkanet.indicators <- sotkanet_indicators(c(4,5,6,7,46,74))
66
- head(sotkanet.indicators$indicator.title)
67
- #> [1] "Mielenterveyden häiriöihin sairaalahoitoa saaneet 0 - 17-vuotiaat / 1 000 vastaavan ikäistä"
68
- #> [2] "Toimeentulotukea saaneet 25 - 64-vuotiaat, % vastaavan ikäisestä väestöstä"
69
- #> [3] "Somaattisen erikoissairaanhoidon vuodeosastohoitopäivät 75 vuotta täyttäneillä / 1 000 vastaavan ikäistä"
70
- #> [4] "0 - 6-vuotiaat, % väestöstä"
71
- #> [5] "0 - 6-vuotiaat, % väestöstä, väestöennuste 2060"
72
- #> [6] "Yhden vanhemman perheet, % lapsiperheistä"
73
+ ``` r
74
+ # Pre-defined list of indicators to save bandwidth
75
+ sotkanet.indicators <- sotkanet_indicators(c(4 ,5 ,6 ,7 ,46 ,74 ))
76
+ head(sotkanet.indicators $ indicator.title )
77
+ # > [1] "Mielenterveyden häiriöihin sairaalahoitoa saaneet 0 - 17-vuotiaat / 1 000 vastaavan ikäistä"
78
+ # > [2] "Toimeentulotukea saaneet 25 - 64-vuotiaat, % vastaavan ikäisestä väestöstä"
79
+ # > [3] "Somaattisen erikoissairaanhoidon vuodeosastohoitopäivät 75 vuotta täyttäneillä / 1 000 vastaavan ikäistä"
80
+ # > [4] "0 - 6-vuotiaat, % väestöstä"
81
+ # > [5] "0 - 6-vuotiaat, % väestöstä, väestöennuste 2060"
82
+ # > [6] "Yhden vanhemman perheet, % lapsiperheistä"
83
+ ```
73
84
74
85
Here is an example of data retrieval and visualization, using indicator
75
86
describing private dental care use among 0-17 years old in 2015-2022.
76
87
77
- library(ggplot2)
78
- library(ggrepel)
79
-
80
- hammashoito <- get_sotkanet(indicators = 1075, years = 2015:2022, genders = "total", region.category = "MAAKUNTA")
81
-
82
- # Indicator title tells what this indicator is about
83
- unique(hammashoito$indicator.title)
84
- #> [1] "Yksityisen hammashuollon käynnit 0 - 17-vuotiailla / 1 000 vastaavan ikäistä"
85
-
86
-
87
- # Some data has to be retrieved separately
88
- hammashoito_metadata <- sotkanet_indicator_metadata(id = 1075)
89
-
90
- plot_caption <- paste0("Lähde: https://sotkanet.fi / ", hammashoito_metadata$organization$title, "\n",
91
- "Datan päiväys ", hammashoito_metadata$`data-updated`)
92
-
93
- plot <- ggplot(hammashoito, aes(x=year, y=primary.value, group=region.title))+
94
- geom_line(aes(color=region.title)) +
95
- geom_point(aes(color=region.title))
96
-
97
- plot + labs(title = "Yksityisen hammashuollon käynnit 2015-2022",
98
- subtitle = "0 - 17-vuotiailla / 1 000 vastaavanikäistä",
99
- x = "Vuosi",
100
- y = "Käyntien lkm",
101
- caption = plot_caption,
102
- color = "Maakunta") +
103
- geom_text_repel(
104
- aes(color = region.title, label = ifelse(year == 2022, region.title, NA_character_)),
105
- xlim = c(2023, 2025),
106
- direction = "both",
107
- hjust = 0,
108
- segment.size = .7,
109
- segment.alpha = .5,
110
- segment.linetype = "dotted",
111
- box.padding = .4,
112
- segment.curvature = -0.1,
113
- segment.ncp = 3,
114
- segment.angle = 20,
115
- size = 3)+
116
- theme(legend.position = "none",
117
- panel.background = element_rect(fill = "linen")) +
118
- scale_x_continuous(
119
- expand = c(0, 0),
120
- limits = c(2015, 2025),
121
- breaks = seq(2015, 2022))
88
+ ``` r
89
+ library(ggplot2 )
90
+ library(ggrepel )
91
+
92
+ hammashoito <- get_sotkanet(indicators = 1075 , years = 2015 : 2022 , genders = " total" , region.category = " MAAKUNTA" )
93
+
94
+ # Indicator title tells what this indicator is about
95
+ unique(hammashoito $ indicator.title )
96
+ # > [1] "Yksityisen hammashuollon käynnit 0 - 17-vuotiailla / 1 000 vastaavan ikäistä"
97
+ ```
98
+
99
+ ``` r
100
+
101
+ # Some data has to be retrieved separately
102
+ hammashoito_metadata <- sotkanet_indicator_metadata(id = 1075 )
103
+
104
+ plot_caption <- paste0(" Lähde: https://sotkanet.fi / " , hammashoito_metadata $ organization $ title , " \n " ,
105
+ " Datan päiväys " , hammashoito_metadata $ `data-updated` )
106
+
107
+ plot <- ggplot(hammashoito , aes(x = year , y = primary.value , group = region.title ))+
108
+ geom_line(aes(color = region.title )) +
109
+ geom_point(aes(color = region.title ))
110
+
111
+ plot + labs(title = " Yksityisen hammashuollon käynnit 2015-2022" ,
112
+ subtitle = " 0 - 17-vuotiailla / 1 000 vastaavanikäistä" ,
113
+ x = " Vuosi" ,
114
+ y = " Käyntien lkm" ,
115
+ caption = plot_caption ,
116
+ color = " Maakunta" ) +
117
+ geom_text_repel(
118
+ aes(color = region.title , label = ifelse(year == 2022 , region.title , NA_character_ )),
119
+ xlim = c(2023 , 2025 ),
120
+ direction = " both" ,
121
+ hjust = 0 ,
122
+ segment.size = .7 ,
123
+ segment.alpha = .5 ,
124
+ segment.linetype = " dotted" ,
125
+ box.padding = .4 ,
126
+ segment.curvature = - 0.1 ,
127
+ segment.ncp = 3 ,
128
+ segment.angle = 20 ,
129
+ size = 3 )+
130
+ theme(legend.position = " none" ,
131
+ panel.background = element_rect(fill = " linen" )) +
132
+ scale_x_continuous(
133
+ expand = c(0 , 0 ),
134
+ limits = c(2015 , 2025 ),
135
+ breaks = seq(2015 , 2022 ))
136
+ ```
122
137
123
138
<img src =" man/figures/README-sotkanet_example-1.png " width =" 90% " />
124
139
@@ -127,15 +142,15 @@ page](http://ropengov.github.io/sotkanet/articles/tutorial.html).
127
142
128
143
### Contributing
129
144
130
- - [ Submit suggestions and bug
131
- reports] ( https://github.com/ropengov/sotkanet/issues ) (provide the
132
- output of ` sessionInfo() ` and ` packageVersion("sotkanet") ` and
133
- preferably provide a [ reproducible
134
- example] ( http://adv-r.had.co.nz/Reproducibility.html ) )
135
- - [ Send a pull request] ( https://github.com/ropengov/sotkanet/pulls )
136
- - [ Star us on the Github page] ( https://github.com/ropengov/sotkanet/ )
137
- - [ See our website] ( https://ropengov.org/community/ ) for additional
138
- contact information
145
+ - [ Submit suggestions and bug
146
+ reports] ( https://github.com/ropengov/sotkanet/issues ) (provide the
147
+ output of ` sessionInfo() ` and ` packageVersion("sotkanet") ` and
148
+ preferably provide a [ reproducible
149
+ example] ( http://adv-r.had.co.nz/Reproducibility.html ) )
150
+ - [ Send a pull request] ( https://github.com/ropengov/sotkanet/pulls )
151
+ - [ Star us on the Github page] ( https://github.com/ropengov/sotkanet/ )
152
+ - [ See our website] ( https://ropengov.org/community/ ) for additional
153
+ contact information
139
154
140
155
### Acknowledgements
141
156
@@ -160,7 +175,7 @@ laitos, THL).
160
175
For information about THL’s open data license and limitation of
161
176
liability, please see their website:
162
177
163
- - In English: [ THL’s open data license and limitation of
164
- liability] ( https://yhteistyotilat.fi/wiki08/display/THLKA/THL%27s+open+data+license+and+limitation+of+liability )
165
- - In Finnish: [ THL: n avoimen datan lisenssi ja
166
- vastuuvapauslauseke] ( https://yhteistyotilat.fi/wiki08/display/THLKA/THL%3An+avoimen+datan+lisenssi+ja+vastuuvapauslauseke )
178
+ - In English: [ THL’s open data license and limitation of
179
+ liability] ( https://yhteistyotilat.fi/wiki08/display/THLKA/THL%27s+open+data+license+and+limitation+of+liability )
180
+ - In Finnish: [ THL: n avoimen datan lisenssi ja
181
+ vastuuvapauslauseke] ( https://yhteistyotilat.fi/wiki08/display/THLKA/THL%3An+avoimen+datan+lisenssi+ja+vastuuvapauslauseke )
0 commit comments