Skip to content

Commit 0c89fb5

Browse files
authored
refactor: ♻️ use Tidyverse functions instead of base and stats (#178)
# Description This also removes the dependency on stats. Needs no review. ## Checklist - [X] Ran `just run-all`
1 parent 35dce13 commit 0c89fb5

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

DESCRIPTION

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Imports:
2424
haven,
2525
purrr,
2626
rlang,
27-
stats,
2827
stringr,
2928
uuid
3029
Suggests:

R/convert.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ get_year_from_filename <- function(path) {
211211
#' @keywords internal
212212
#' @noRd
213213
create_part_uuid <- function() {
214-
substr(uuid::UUIDgenerate(), 0, 6)
214+
stringr::str_sub(uuid::UUIDgenerate(), start = 1, end = 6)
215215
}
216216

217217
#' Create a consistent Arrow schema from a data frame

R/simulate.R

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@
1717
#' @examples
1818
#' simulate_register(register = "kontakter", year = c("1999", "2000"))
1919
simulate_register <- function(register, year = "", n = 1000) {
20-
names <- ifelse(year == "", register, paste(register, year, sep = "_"))
20+
names <- dplyr::if_else(
21+
year == "",
22+
register,
23+
paste(register, year, sep = "_")
24+
)
2125
purrr::map(names, \(name) {
2226
osdc::simulate_registers(registers = register, n = n)[[1]]
2327
}) |>
24-
stats::setNames(names)
28+
purrr::set_names(names)
2529
}
2630

2731
#' Save a list of data frames as SAS files
@@ -42,7 +46,7 @@ save_as_sas <- function(data_list, path) {
4246
purrr::iwalk(data_list, \(df, name) {
4347
suppressWarnings(haven::write_sas(
4448
df,
45-
fs::path(path, paste0(name, ".sas7bdat"))
49+
fs::path(path, glue::glue("{name}.sas7bdat"))
4650
))
4751
})
4852
invisible(path)

0 commit comments

Comments
 (0)