R/standardize_main_colnames.R

Defines functions standardize_main_colnames

standardize_main_colnames <- function(query,
                                      colmap, 
                                      verbose=TRUE){
    
    messager("Standardizing main column names.",v=verbose)
    #### Determine which cols are actually available ###
    colmap2 <- unlist(colmap)
    colmap2 <- colmap2[!colmap2 %in% c("TRUE","FALSE",TRUE,FALSE)]
    colmap2 <- colmap2[unname(colmap2) %in% colnames(query)]   
    #### Rename ####
    query <- data.table::data.table(query)
    data.table::setnames(query, 
                         old = unname(colmap2),
                         new = names(colmap2),
                         skip_absent = TRUE)  
    return(query)
}
RajLabMSSM/echodata documentation built on Nov. 21, 2023, 8 a.m.