Skip to content

1.0.7.3 - fix for labelled not being treated as numeric + uplift.#14

Merged
conig merged 23 commits intomasterfrom
1.0.7.3
Nov 3, 2025
Merged

1.0.7.3 - fix for labelled not being treated as numeric + uplift.#14
conig merged 23 commits intomasterfrom
1.0.7.3

Conversation

@conig
Copy link
Copy Markdown
Owner

@conig conig commented Nov 3, 2025

No description provided.

@conig conig requested a review from Copilot November 3, 2025 22:50
@conig conig marked this pull request as ready for review November 3, 2025 22:52
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds support for haven-labelled variables in the corx package by integrating the labelled package to handle value labels. The main improvements include replacing deprecated tidyselect::vars_select with a custom eval_select_names function, improving the class checking mechanism to handle labelled variables, and applying code formatting/style improvements throughout the codebase.

  • Added support for haven-labelled variables by using labelled::remove_labels() in class checking
  • Replaced deprecated tidyselect::vars_select() with a custom eval_select_names() function
  • Applied extensive code formatting improvements (spacing, braces, indentation)

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
R/utils.R New utility function eval_select_names() to replace deprecated tidyselect::vars_select()
R/corx.R Updated to use eval_select_names(), improved class checking to handle labelled variables, extensive code formatting
R/cormat_list.R Code formatting improvements (spacing, line breaks)
man/corx.Rd Improved documentation for the round parameter
tests/testthat/test_value_labels.R New test for value labels functionality
tests/testthat/test_describe.R New tests for describe parameter functionality
NEWS.md Updated with version 1.0.7.3 changes
DESCRIPTION Version bump to 1.0.7.3, added labelled and rlang dependencies
.github/workflows/R-CMD-check.yaml Enhanced CI workflow with multi-OS testing and docs build

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

R/utils.R Outdated
@@ -0,0 +1,32 @@
# replacement for tisyselect::vars_select
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

Corrected spelling of 'tisyselect' to 'tidyselect'.

Suggested change
# replacement for tisyselect::vars_select
# replacement for tidyselect::vars_select

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

fixed

testthat::test_that("value_labels works correctly", {
iris_new <- iris |>
labelled::set_value_labels(
Sepal.Length = c(mediumlengh = 5.1, lowerlength = 4.6)
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

Corrected spelling of 'mediumlengh' to 'mediumlength'.

Suggested change
Sepal.Length = c(mediumlengh = 5.1, lowerlength = 4.6)
Sepal.Length = c(mediumlength = 5.1, lowerlength = 4.6)

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

fixed

R/corx.R Outdated
text <- gsub("\\bNA\\b", crayon::red("NA"), text) # make NAs red
text <- gsub("\\*", crayon::yellow("*"),text) # make stars yelloe
text <- gsub("\\ - ", crayon::silver(" - "),text) # make dashes silver
text <- gsub("\\*", crayon::yellow("*"), text) # make stars yelloe
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

Corrected spelling of 'yelloe' to 'yellow'.

Suggested change
text <- gsub("\\*", crayon::yellow("*"), text) # make stars yelloe
text <- gsub("\\*", crayon::yellow("*"), text) # make stars yellow

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

fixed

Comment on lines +372 to +375
if (remove_lead) {
f_matrix[] <-
gsub("0\\.", ".", f_matrix) #remove leading zeros if requested
gsub("0\\.", ".", f_matrix)
} #remove leading zeros if requested
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

[nitpick] The closing brace comment should be on a separate line or moved inside the block for better code style consistency. Consider moving the comment to line 373 before the gsub call.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

ignored

R/corx.R Outdated
Comment on lines +517 to +518
any(sapply(classes, function(y) {
x <- labelled::remove_labels(x)
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

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

The labelled::remove_labels(x) is called inside a loop for each class check. This could be inefficient if there are multiple classes to check. Consider removing labels once before the sapply loop: x <- labelled::remove_labels(x) before line 517.

Suggested change
any(sapply(classes, function(y) {
x <- labelled::remove_labels(x)
x <- labelled::remove_labels(x)
any(sapply(classes, function(y) {

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This has been implemented

@conig conig merged commit 375f28d into master Nov 3, 2025
6 checks passed
@conig
Copy link
Copy Markdown
Owner Author

conig commented Nov 3, 2025

closes #11

@conig conig deleted the 1.0.7.3 branch November 3, 2025 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants