Skip to content

Commit

Permalink
V0.10.5 (#100)
Browse files Browse the repository at this point in the history
* fix age issue in multiple years

* Increment version number to 0.10.5

* Update NEWS.md
  • Loading branch information
lizihao-anu authored Sep 17, 2024
1 parent daa6263 commit 66f3534
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: slfhelper
Title: Useful functions for working with the Source Linkage Files
Version: 0.10.4
Version: 0.10.5
Authors@R: c(
person("Public Health Scotland", , , "phs.source@phs.scot", role = "cph"),
person("James", "McMahon", , "james.mcmahon@phs.scot", role = c("aut"),
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# slfhelper 0.10.5
* Bug - fix age as an integer when reading multiple years

# slfhelper 0.10.4
* Bug - Fix build tests
* New feature - Additional documentation
Expand Down
10 changes: 6 additions & 4 deletions R/read_slf.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ read_slf <- function(
# Check if recid/hscp is among the selected columns
recid_present <- "recid" %in% selected_columns
hscp_present <- "hscp2018" %in% selected_columns
age_present <- "age" %in% selected_columns

# check if we need add extra recid/hscp to do filter
# remember to remove recid/hscp later
Expand Down Expand Up @@ -109,6 +110,11 @@ read_slf <- function(
slf_table <- slf_table %>% dplyr::select(-c("hscp2018"))
}

if (age_present){
slf_table <- slf_table %>%
dplyr::mutate(age = as.integer(.data$age))
}

return(slf_table)
}
)
Expand Down Expand Up @@ -184,10 +190,6 @@ read_slf_episode <- function(
data <- data %>%
dplyr::mutate(keytime2 = hms::as_hms(.data$keytime2))
}
if ("age" %in% names(data)) {
data <- data %>%
dplyr::mutate(age = as.integer(age))
}

return(data)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-multiple_years.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test_that("read multiple years works for individual file", {

# Read in multiple years
indiv <- read_slf_individual(c("1718", "1819"),
col_select = c("year", "anon_chi")
col_select = c("year", "anon_chi", "age")
) %>%
dplyr::group_by(year) %>%
dplyr::slice_sample(n = 50) %>%
Expand Down

0 comments on commit 66f3534

Please sign in to comment.