R/mosaicShannonSimpson.R

Defines functions mosaicdiv

Documented in mosaicdiv

#

mosaicdiv<-function(x, decreasing=NULL, ...)
{
if(!any(class(x)%in%c("Shannonci","Simpsonci"))){warning("This is a convenience function for objects of class 'Shannonci' or 'Simpsonci'!")}

tab<-x$sample.estimate$table

aargs<-list(...)

if(is.null(aargs$las))
 {aargs$las<-1}

if(is.null(aargs$main))
 {aargs$main<-""}


if(is.null(decreasing))
{
aargs$x<-tab
do.call("mosaicplot", aargs)
}
else{

if(!is.logical(decreasing)) 
 {stop("decreasing should be either TRUE, FALSE or NULL")}

if(decreasing)
{
cs<-apply(tab, 2, sum)
CO<-order(cs, decreasing=TRUE)
aargs$x<-tab[,CO]
do.call("mosaicplot", aargs)
}


if(!decreasing)
{
cs<-apply(tab, 2, sum)
CO<-order(cs, decreasing=FALSE)
aargs$x<-tab[,CO]
do.call("mosaicplot", aargs)
}
}

}

Try the MCPAN package in your browser

Any scripts or data that you put into this service are public.

MCPAN documentation built on May 1, 2019, 8:04 p.m.