R/change_names.R

Defines functions change_names

Documented in change_names

change_names <-
function(rowOrCol,Table,nameForTable){
    
    if(rowOrCol=="row"){
        IndexForNewName=match(rownames(Table),nameForTable[,1])
        rownames(Table)=nameForTable[,2][IndexForNewName]
    }else if(rowOrCol=="col"){
        IndexForNewName=match(colnames(Table),nameForTable[,1])
        colnames(Table)=nameForTable[,2][IndexForNewName]
    }else{
        stop("Enter either \"row\" or \"col\"")  
    } 
    
    return(Table)
}
peterwu19881230/microbialPhenotypes documentation built on March 19, 2021, 6:36 a.m.