Skip to content

Commit

Permalink
updates to address OM column name problem
Browse files Browse the repository at this point in the history
  • Loading branch information
AlisonLanski committed Dec 8, 2024
1 parent b1af7c2 commit bb50534
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: IPEDSuploadables
Title: Transforms Institutional Data into Text Files for IPEDS Automated Import/Upload
Version: 2.9.1
Version: 2.10.0
Authors@R: c(
person(given = "Alison", family = "Lanski",
role = c("aut", "cre"),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#IPEDSuploadables 2.10.0
* Updating incorrect column name in Outcome Measures vignette
* Added quality check for correct column name in OM data prep script

# IPEDSuploadables 2.9.1
* Changing data load method in vignettes to avoid error on old Mac OS checks
* Making function documentation a bit more uniform
Expand Down
8 changes: 8 additions & 0 deletions R/prep_om_data_frame.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ prep_om_data_frame <- function(df) {

colnames(df) <- stringr::str_to_upper(colnames(df))


if("EXCLUSION" %in% colnames(df) & sum(grepl(x = df$EXCLUSION, "clude")) > 1){
df <- df %>%
dplyr::rename(COHORTSTATUS = .data$EXCLUSION)
}


df <- df %>%
dplyr::mutate(UNITID = as.character(.data$UNITID),
EXCLUSION = dplyr::case_when(
Expand All @@ -24,6 +31,7 @@ prep_om_data_frame <- function(df) {

if (sum(is.na(df$EXCLUSION)) > 0) {
warning(paste0("Check CohortStatus: invalid values found for StudentId: ", toString(df$STUDENTID[is.na(df$EXCLUSION)])))
warning("Please use the CohortStatus column with values of 'Include' or 'Exclude' to indicate exclusions.")
}

return(df)
Expand Down
Binary file modified data/specs_OM.rda
Binary file not shown.
7 changes: 7 additions & 0 deletions tests/testthat/test-prep-scripts.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ hr_df <- data.frame(unitid = 123456,

om_df <- data.frame(unitid = 123456,
cohortstatus = c("Include", "Exclude"))
om_df2 <- data.frame(unitid = 123456,
exclusion = c("Include", "Exclude"))
om_df3 <- data.frame(unitid = "000000",
studentid = c("A", "B", "C"),
exclusion = c("Include", "Exclude", "TRUE"))


####
Expand Down Expand Up @@ -112,6 +117,7 @@ test_that("Funky data used for recoding will throw warning messages", {
expect_warning(prep_om_data_frame(data.frame(unitid = 123456,
studentid = c('AAA', 'BBB', 'CCC'),
cohortstatus = c("Amy", "Bob", "Include"))), "Check CohortStatus")
expect_warning(prep_om_data_frame(om_df3))
})


Expand All @@ -124,6 +130,7 @@ test_that("Funky data used for recoding will throw warning messages", {

test_that("OM prep recoding comes out as expected", {
expect_equal(prep_om_data_frame(om_df)$EXCLUSION, c(FALSE, TRUE))
expect_equal(prep_om_data_frame(om_df2)$EXCLUSION, c(FALSE, TRUE))
})


Expand Down

0 comments on commit bb50534

Please sign in to comment.