leghead: Generate a Color Coded Legend dataframe via head and sum.

Description Usage Arguments Value See Also Examples

View source: R/aggregate.R

Description

'leghead' is part 'head' and part 'summary'. It works best on a sorted dataframe where all you are interestesd in only the most (or least) abundant rows. An ideal place to use it is in a legend for ~lognormally distributed data. Additionally, an optional row-wise color coding column is added (the color 'gray' is used for missing row names).

Usage

1
2
leghead(x, n=7, tabulate=FALSE, colors=TRUE, na.name='NA', 
        na.col = "white", other.col = "gray",  na.last = TRUE)

Arguments

x

dataframe or table you wish to summarize

n

the number of rows you wish to display as is

colors

list of vectors or a dataframe

tabulate

the column name to tabulate on if x is an untabulated dataframe and FALSE otherwise

na.name

the new rowname for a row with a missing name

na.col

color for rows labeled as 'NA'

other.col

color for the rows labeled as 'unknown'

na.last

boolean specifying if the na category should be listed last in the table.

Value

A truncated dataframe with a new bottom row summarizing all the truncated ones.

See Also

summary, head, sstable

Examples

1
2
3
4
5
 e <- data.frame(a=runif(12),b=runif(12), z=rep(letters[13:18],2),w=rep(letters[20:23],3))
tab <- sstable(e, idx.clmns=c('z'), ct.clmns=c('a','b'))
lh <- leghead(tab)
plot(x=lh$a, y=lh$b, cex=lh$sum*3, col=lh$color, pch=20)
legend('topleft',legend=rownames(lh), col=lh$color, pch=20)

caroline documentation built on May 29, 2017, 12:09 p.m.

Related to leghead in caroline...