Skip to content

Commit

Permalink
conditional area_code update
Browse files Browse the repository at this point in the history
only mutate area_code if the column exists
also change filtering from across to if_any as dplyr guidlines
  • Loading branch information
peteowen1 authored Feb 7, 2024
1 parent 52fd632 commit 99f3587
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions R/seifa.R
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,18 @@ get_seifa_index_sheet <- function(filename, sheetname, structure = c("sa1", "sa2
col_names = column_names,
na = c("", "NA", "-")
) %>%
dplyr::filter(across(ends_with("_code"), ~ !is.na(.x))) %>%
dplyr::filter(if_any(ends_with("_code"), ~ !is.na(.x))) %>%
select(-starts_with("blank")) %>%
mutate(
area_code = as.character(area_code),
structure = structure,
year = year
) %>%
mutate(across(
.cols = any_of("area_code"), # Specify the column name
.fns = ~ as.character(.) # Conditionally convert to character
)) %>%
relocate(structure)
})

return(df)
}

0 comments on commit 99f3587

Please sign in to comment.