Plot discrete categorical values belonging to class labels. Each category can have a unique color and a color for missing if exists. User has the option to perform an association test and output p-value and a contingency table summarizing count and proportion.

panelet_category(pp,pp.col,gr, var.n="var.n",NA.flag=FALSE,
NA.col="grey", get.pval=FALSE, border=FALSE, border.col="black", legend=FALSE,...)

Arguments

pp

required. vector. A vector of categorical values of interest

pp.col

required. vector. A vector of colors of the same length as the unique values in the categorical variable of interest

gr

required. vector. Class labels as passed to panelet_group. If NULL assumes no grouping, and outputs median and range if get.pval=TRUE

var.n

character. A character specifying the name of the variable. Set to blank "" if you want to omit printing any text. See cex

NA.flag

logical, default is FALSE. see get.colvector for details

NA.col

default is "grey". see get.colvector for details

get.pval

logical, default is FALSE. Perform Fisher's Exact Test to test for association between the group variable and the categorical variable of interest. If TRUE a table summarizing count and proportion is returned as well.

border

logical, default is FALSE. Add a border outside panelet and demarcating group boundaries

border.col

default is "black", if border=TRUE, you can specify the color of the border to be plotted. Plots outside the panelet and class boundaries

legend

logical. default is FALSE. if TRUE it returns a key specifying each color assigned to the categories. Only displays in the plot with makepanel

...

pass optional arguments here

Details

... can pass other parameters. Use it for controlling names and colors of panelets via cex, col. border line type and thickness can be controlled via lty and lwd respectively.

A colored panelet of categorical values is plotted. Make sure the variable is ordered according to the group labels in panelet_group.

Value

A colored panelet of categorical values is plotted.

key

if legend = TRUE, returns a key mapping the group labels to specific color

tab

if get.pval =TRUE, returns a table summarizing the counts and proportions along with a p-value from Fisher's Exact Test

See also

makepanel

Examples

#adjust margins and number of panelet values par(mfrow=c(5,1),mar=c(0,8,0,14)) #sort the entire data frame according to the group solution you are interested in mtcars.sort = mtcars[order(mtcars$cyl),] #plot group panelet_group(gr=mtcars.sort$cyl, gr.col=c("red","blue","green"), gr.name="cyl",cex=2, border=TRUE, legend=FALSE)
#> $key #> [,1] [,2] [,3] #> "4" "6" "8" #> col "red" "blue" "green" #>