R/getMDFR.ZScoresForABData.R

Defines functions getMDFR.ZScoresForABData

Documented in getMDFR.ZScoresForABData

#'
#'@title Get z-scores for abundance, biomass data from fits to data as dataframe
#'
#'@description Function to get z-scores for abundance, biomass data from fits to data as dataframe.
#'
#'@param afits - 
#'@param verbose - flag (T/F) to print dagnostic info
#'
#'@return dataframe
#'
#'@export
#'
getMDFR.ZScoresForABData<-function(afits,
                                   verbose=FALSE){
    if (verbose) cat("---Running getMDFR.ZScoresForABData(...).\n");
    
    nf<-length(afits);
    if (verbose) cat("----number of fits =",nf,"\n");

    mdfr<-NULL;
    for (n in 1:nf){
        afit<-afits[[n]];
        if (!is.null(afit)){
            nll<-afit$nll;
            pdfType<-nll$nll.type;
            if (tolower(pdfType)!='none'){
                dfrp<-data.frame(x=afit$x,m=afit$m,s=afit$s,
                                 y=as.numeric(names(nll$mod)),
                                 val=nll$zscrs,var='zscr');
                mdfr<-rbind(mdfr,dfrp);
            }
        }
    }
        
    mdfr$x<-gsub("_"," ",tolower(mdfr$x),fixed=TRUE);
    mdfr$m<-gsub("_"," ",tolower(mdfr$m),fixed=TRUE);
    mdfr$s<-gsub("_"," ",tolower(mdfr$s),fixed=TRUE);
    
    if (verbose) cat("---Done running getMDFR.ZScoresForABData(...).\n");
    return(mdfr);
}
wStockhausen/rTCSAM2015 documentation built on May 3, 2019, 7:14 p.m.