Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/aFIPC.R
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,8 @@ autoFIPC <-
if (
!is.na(newFormItemName) &&
!is.na(oldFormItemName) &&
(length(stats::na.omit(unique(newFormModel@Data$data[, newFormItemName]))) ==
length(stats::na.omit(unique(oldFormModel@Data$data[, oldFormItemName]))))
(sum(!is.na(unique(newFormModel@Data$data[, newFormItemName]))) ==
sum(!is.na(unique(oldFormModel@Data$data[, oldFormItemName]))))
) {
message(
'applying ',
Expand Down
2 changes: 1 addition & 1 deletion R/surveyFA.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ surveyFA <- function(
response_data <- as.data.frame(data)
response_data <-
response_data[, vapply(response_data, function(column) {
nunique <- length(unique(stats::na.omit(column)))
nunique <- sum(!is.na(unique(column)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 Info: Regression guard pins the pre-refactor idiom

The category-count guard in test-optimization-equivalence.R still pins length(na.omit(unique(x))), while the source now uses sum(!is.na(unique(x))). The two are equivalent for atomic vectors, so behavior is unchanged, but the guard no longer mirrors the implementation and will not catch a future change to the new idiom.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📝 Info: na.omit replacement is numerically equivalent

Rewriting length(stats::na.omit(unique(x))) and length(unique(stats::na.omit(x))) to sum(!is.na(unique(x))) preserves the distinct-non-missing count: unique() collapses duplicate NAs to one, !is.na drops it, sum counts the rest. The category-count guard in surveyFA and the common-item guard in aFIPC keep their prior meaning.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

nunique >= 2L
}, logical(1L))]

Expand Down