Skip to content

Commit

Permalink
v0.2.12
Browse files Browse the repository at this point in the history
### Bug fixes
* `get_assoc()` - Drop empty factor levels if using haven::as_factor()
* `get_assoc()` - Correctly identify covariate variable names when using haven::as_factor()

### Changes
* Add light switch to pkgdown site
  • Loading branch information
lcpilling committed Oct 7, 2024
1 parent eb5c816 commit ba3a292
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: lukesRlib
Title: My library of R functions I sometimes find useful
Version: 0.2.11
Version: 0.2.12
Authors@R: c(person("Luke", "Pilling",
email = "L.Pilling@exeter.ac.uk",
role = c("aut", "cre"),
Expand Down
11 changes: 11 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# lukesRlib 0.2.12 (7th Oct 2024)

### Bug fixes
* `get_assoc()` - Drop empty factor levels if using haven::as_factor()
* `get_assoc()` - Correctly identify covariate variable names when using haven::as_factor()

### Changes
* Add light switch to pkgdown site


# lukesRlib 0.2.11 (30th Sept 2024)

### Changes
Expand All @@ -7,6 +17,7 @@
* Update example data categorical variables to include labels
* Fix NEWS formatting


# lukesRlib 0.2.10 (6th June 2024)

### Changes
Expand Down
4 changes: 2 additions & 2 deletions R/get_assoc.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ get_assoc = function(
# check variables are all in d
if (any(! x %in% colnames(d))) stop("Not all exposure variables are in the provided data")
if (any(! yy %in% colnames(d))) stop("Not all outcome variables are in the provided data")
z_vars = stringr::str_replace_all(z, " |as.factor\\(|\\)", "") |>
z_vars = stringr::str_replace_all(z, " |as.factor\\(|haven::|\\)", "") |>
stringr::str_split_1("\\+|\\*") |>
purrr::keep(\(x) stringr::str_length(x)>0)
if (any(! z_vars %in% colnames(d))) stop("Not all covariate variables are in the provided data")
Expand Down Expand Up @@ -240,7 +240,7 @@ get_assoc1 = function(

# exposure variable - categorical?
# if using haven, mutate the actual data
if (af & !af_base) d = d |> dplyr::mutate( !! rlang::sym(x) := haven::as_factor( !! rlang::sym(x) ) )
if (af & !af_base) d = d |> dplyr::mutate( !! rlang::sym(x) := droplevels( haven::as_factor( !! rlang::sym(x) ) ) )
if (af) xx = paste0("as.factor(",xx,")")

# scale exposure or outcome?
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
My library of R functions I sometimes find useful

<!-- badges: start -->
[![](https://img.shields.io/badge/version-0.2.11-informational.svg)](https://github.com/lcpilling/lukesRlib)
[![](https://img.shields.io/badge/version-0.2.12-informational.svg)](https://github.com/lcpilling/lukesRlib)
[![](https://img.shields.io/github/last-commit/lcpilling/lukesRlib.svg)](https://github.com/lcpilling/lukesRlib/commits/master)
[![](https://img.shields.io/badge/lifecycle-experimental-orange)](https://www.tidyverse.org/lifecycle/#experimental)
[![DOI](https://zenodo.org/badge/590063045.svg)](https://zenodo.org/badge/latestdoi/590063045)
Expand Down
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
url: https://lcpilling.github.io/lukesRlib/
template:
bootstrap: 5
light-switch: true

authors:
Luke Pilling:
Expand Down

0 comments on commit ba3a292

Please sign in to comment.