Skip to content

Commit

Permalink
removing geofi-examples and geofi dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Kainu committed Aug 26, 2024
1 parent 3af4539 commit c4fa35a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 87 deletions.
45 changes: 0 additions & 45 deletions vignettes/read_data.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -130,48 +130,3 @@ ggplot(d_plot, aes(x = vuosi, y = saaja_lkm, fill = ikaryhma)) +
```




```{r}
d_opintotuki <- kelaopendata::get_data(
data_id = d_id,
sql = "WHERE etuus = 'Opintolainan valtiontakaus' AND
aikatyyppi = 'Vuosi' AND
vuosi = '2023' AND
etuus = 'Opintolainan valtiontakaus' AND
oppilaitos_peruste = 'Viimeisin oppilaitos'
"
)
d_opintotuki
library(geofi)
muni <- get_municipalities()
```

Next, let's filter the data locally in R a bit more.

```{r}
d_plot <- d_opintotuki %>%
# Exclude
filter(sukupuoli != "Tuntematon",!oppilaitosaste %in% c("Tieto puuttuu", "Yhteensä")) %>%
filter(oppilaitosaste == "Yliopistot",
!is.na(sukupuoli)) %>%
group_by(kunta_nro,sukupuoli) %>%
summarise(saaja_lkm = sum(saaja_lkm)) %>%
ungroup() %>%
mutate(municipality_code = as.integer(kunta_nro))
d_plot_sf <- left_join(muni,d_plot)
```


Finally, let's draw a plot on recipients by gender and type of institution


```{r, fig.width=8, fig.height=12}
library(ggplot2)
ggplot(d_plot_sf, aes(fill = saaja_lkm)) +
geom_sf() +
facet_wrap(~ sukupuoli) +
theme_light()
```

42 changes: 0 additions & 42 deletions vignettes/read_data_csv.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -132,45 +132,3 @@ ggplot(d_plot, aes(x = vuosi, y = saaja_lkm, fill = ikaryhma)) +
```




```{r}
d_opintotuki <- d_raw %>%
filter(etuus == 'Opintolainan valtiontakaus',
aikatyyppi == 'Vuosi',
vuosi == 2023,
etuus == 'Opintolainan valtiontakaus',
oppilaitos_peruste == 'Viimeisin oppilaitos')
d_opintotuki
library(geofi)
muni <- get_municipalities()
```

Next, let's filter the data locally in R a bit more.

```{r}
d_plot <- d_opintotuki %>% #count(sukupuoli)
# Exclude
filter(sukupuoli != "Tuntematon",!oppilaitosaste %in% c("Tieto puuttuu", "Yhteensä")) %>%
filter(oppilaitosaste == "Yliopistot",
!is.na(sukupuoli)) %>%
group_by(kunta_nro,sukupuoli) %>%
summarise(saaja_lkm = sum(saaja_lkm)) %>%
ungroup() %>%
mutate(municipality_code = as.integer(kunta_nro))
d_plot_sf <- left_join(muni,d_plot)
```


Finally, let's draw a plot on recipients by gender and type of institution


```{r, fig.width=8, fig.height=12}
library(ggplot2)
ggplot(d_plot_sf, aes(fill = saaja_lkm)) +
geom_sf() +
facet_wrap(~ sukupuoli) +
theme_light()
```

0 comments on commit c4fa35a

Please sign in to comment.