Skip to content

Commit

Permalink
Style: Rename fix files according to geo level
Browse files Browse the repository at this point in the history
  • Loading branch information
ybkamaleri committed Oct 11, 2023
1 parent 20f1498 commit ed5e20e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
7 changes: 4 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# norgeo 2.4.2 (dev)
- Get future data from API. Thank to @raniets for the request and proposed solution (#83)
- Fix error on the date in `date_future()`
- Fix geo codes manually when necessary (#84). This is done by sourcing
[geo-fix.R](https://github.com/helseprofil/config/tree/main/geo/geo-fix.R)
file. Use argument `fix = FALSE` to deactivate executing `geo-fix.R` file.
- Fix geo codes manually when necessary (#84). This is done by sourcing [config
files](https://github.com/helseprofil/config/tree/main/geo) according to their
granularity level. Use argument `fix = FALSE` to deactivate executing
these file.

# norgeo 2.3.1
- Replace `httr` package with `httr2` package.
Expand Down
19 changes: 15 additions & 4 deletions R/track-change.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#'
#' @inheritParams get_code
#' @param fix Default is TRUE. Use external codes to fix geo changes manually.
#' The codes is sourced from \href{https://github.com/helseprofil/config/blob/main/geo/geo-fix.R}{geo-fix.R} file.
#' The codes is sourced from
#' \href{https://github.com/helseprofil/config/blob/main/geo/}{config} files
#' depending on the granularity levels.
#' @return A dataset of class `data.table` consisting all older codes from
#' previous years until the selected year in `to` argument and what these
#' older codes were changed into. If the codes have not changed then the value
Expand Down Expand Up @@ -63,7 +65,7 @@ track_change <- function(type = c(
if (!fix)
return(DT)

DT <- alter_manual(DT)
DT <- alter_manual(DT, type)

return(DT)
}
Expand Down Expand Up @@ -160,9 +162,18 @@ grunnkrets_check <- function(type, to = NULL){

## Maually alter dataset especially when there are splitting codes ie. issue 84
## Codes should be in config repo file
alter_manual <- function(DT){
alter_manual <- function(DT, type){

http <- "https://raw.githubusercontent.com/helseprofil/config/main/geo/geo-fix.R"
baseURL <- "https://raw.githubusercontent.com/helseprofil/config/main/geo/"

fileName <- switch(type,
fylke = "geo-fylke.R",
kommune = "geo-kommune.R",
bydel = "geo-bydel.R",
grunnkrets = "geo-grunnnkrets.R"
)

http <- paste0(baseURL, fileName)

if (check_url(http)){
message("Run source file ", http)
Expand Down
2 changes: 1 addition & 1 deletion docs/news/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 comment on commit ed5e20e

@ybkamaleri
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is related to issue #84

Please sign in to comment.