R/add_col.R

Defines functions add_col

add_col <- function(dt,
                    col,
                    force_new = FALSE) {
    col_exists <- col %in% names(dt)
    if (col_exists) {
        if (force_new) {
            message(col, " already exists (replacing).")
            return(TRUE)
        } else {
            message(col, " already exists (keeping original).")
            return(FALSE)
        }
    } else {
        return(TRUE)
    }
}
neurogenomics/MungeSumstats documentation built on Aug. 10, 2024, 5:59 a.m.