R/check_track_heights.R

Defines functions check_track_heights

check_track_heights <- function(TRKS,
                                track_heights=NULL,
                                default_height=1,
                                verbose=TRUE){
    messager("+ Checking track heights...",v=verbose)
    if(is.null(track_heights)){
        track_heights <- heights_dict(keys=names(TRKS))
    } else {
        # Ensures n TRKS == n track_heights,
        ## even if user-supplied track_heights is > or < than n TRKS.
        track_heights <- track_heights[seq_len(length(TRKS))]
    }
    track_heights <- track_heights[!is.na(track_heights)]
    
    if(length(track_heights)<length(TRKS)){
        messager("Filling in missing track lengths with",default_height,v=verbose)
        n_missing <- length(TRKS)-length(track_heights)
        track_heights <- c(track_heights, rep(default_height,n_missing))
    }
    return(track_heights)
}
bschilder/echoplot documentation built on Oct. 26, 2023, 6:55 p.m.