diff --git a/DESCRIPTION b/DESCRIPTION index 8eaba20..bb82e2f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: sorvi Type: Package Title: Functions for Finnish Open Data Version: 0.8.21 -Date: 2023-08-21 +Date: 2023-10-20 Authors@R: c( person("Leo", "Lahti", , "leo.lahti@iki.fi", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-5537-637X")), @@ -20,7 +20,7 @@ URL: https://github.com/ropengov/sorvi, https://CRAN.R-project.org/package=sorvi, https://ropengov.github.io/sorvi/ Depends: - R (>= 3.5.0) + R (>= 3.6.0) Imports: dlstats, dplyr, diff --git a/NAMESPACE b/NAMESPACE index 2050888..1f25832 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -37,6 +37,7 @@ importFrom(rlang,.data) importFrom(rvest,html_elements) importFrom(rvest,html_text) importFrom(sf,st_as_sf) +importFrom(sf,st_drop_geometry) importFrom(sf,st_is_empty) importFrom(tidyr,tibble) importFrom(utils,read.csv) diff --git a/NEWS.md b/NEWS.md index d3e486c..c78d6d3 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ +# sorvi 0.8.22 (2023-10-20) + +### BUG FIXES + +- Fixed function argument `type` in `get_municipalities()` - now it actually affects the class of the returned object! New default object type is `sf` and other options are `tibble` and `data.frame` +- Fixed Loimaan mlk / Loimaa lk and Metsämaa division / merger information in the datasets `sorvi::kunnat1865_2021` and `sorvi::polygons1909_2009` + # sorvi 0.8.21 (2023-08-21) ### NEW FEATURES diff --git a/R/select_municipalities_by_year.R b/R/select_municipalities_by_year.R index f18daf8..854f920 100644 --- a/R/select_municipalities_by_year.R +++ b/R/select_municipalities_by_year.R @@ -3,19 +3,19 @@ #' pick a certain year and return an output that contains the most recent #' information on each municipality. #' @param year a year between 1865-2020 -#' @param type either "data.frame" or "sf" +#' @param type either "data.frame", "tibble" or "sf" #' @return a data.frame or sf object #' @details See dataset "kunnat1865_2021" #' @importFrom dplyr group_by arrange filter left_join #' @importFrom magrittr %>% #' @importFrom checkmate assert_integer assert_choice -#' @importFrom sf st_is_empty st_as_sf +#' @importFrom sf st_is_empty st_as_sf st_drop_geometry #' @source Data attribution: FinnONTO Consortium: \url{https://seco.cs.aalto.fi/projects/finnonto/} #' @export #' @author Pyry Kantanen -get_municipalities <- function(year = 2002, type = "data.frame") { +get_municipalities <- function(year = 2002, type = "sf") { checkmate::assert_double(year, lower = 1865, upper = 2020) - checkmate::assert_choice(type, choices = c("data.frame", "sf")) + checkmate::assert_choice(type, choices = c("data.frame", "tibble", "sf")) kunnat1865_2021 <- sorvi::kunnat1865_2021 polygons1909_2009 <- sorvi::polygons1909_2009 @@ -48,6 +48,12 @@ get_municipalities <- function(year = 2002, type = "data.frame") { } } + if (type == "data.frame") { + filtered_dataset <- sf::st_drop_geometry(filtered_dataset) + filtered_dataset <- as.data.frame(filtered_dataset) + } else if (type == "tibble") { + filtered_dataset <- sf::st_drop_geometry(filtered_dataset) + } return(filtered_dataset) } diff --git a/data/kunnat1865_2021.rda b/data/kunnat1865_2021.rda index fed2582..3ea0865 100644 Binary files a/data/kunnat1865_2021.rda and b/data/kunnat1865_2021.rda differ diff --git a/data/polygons1909_2009.rda b/data/polygons1909_2009.rda index 99db5d9..9d887eb 100644 Binary files a/data/polygons1909_2009.rda and b/data/polygons1909_2009.rda differ diff --git a/man/get_municipalities.Rd b/man/get_municipalities.Rd index 70150e2..205b60b 100644 --- a/man/get_municipalities.Rd +++ b/man/get_municipalities.Rd @@ -7,12 +7,12 @@ Data attribution: FinnONTO Consortium: \url{https://seco.cs.aalto.fi/projects/finnonto/} } \usage{ -get_municipalities(year = 2002, type = "data.frame") +get_municipalities(year = 2002, type = "sf") } \arguments{ \item{year}{a year between 1865-2020} -\item{type}{either "data.frame" or "sf"} +\item{type}{either "data.frame", "tibble" or "sf"} } \value{ a data.frame or sf object