Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
andersone1 committed Nov 20, 2024
1 parent 3cc6c68 commit 0807689
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions R/identify-subject-cols.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,17 @@ identify_subject_cols <- function(.df, .subject_col) {
) %>%
# Transform the data into a long format with column names and their corresponding boolean values
tidyr::pivot_longer(
cols = tidyselect::everything(),
names_to = "name",
values_to = "all_constant"
cols = tidyselect::everything()
) %>%
# Filter to retain only those columns that are constant within each subject across the entire data frame
dplyr::filter(all_constant) %>%
dplyr::filter(value) %>%
# Extract the names of these columns
dplyr::pull(name)
dplyr::pull(name) %>%
sort()

out <-
if (length(constant_cols) > 0) {
sort(constant_cols)
} else {
"none"
}
if (length(constant_cols) == 0) {
constant_cols <- "none"
}

out
constant_cols
}

0 comments on commit 0807689

Please sign in to comment.