hierobrk {plotrix} | R Documentation |
Breaks down a numeric element of a data frame by one or more categorical elements.
hierobrk(formula,data,maxlevels=10,mct=mean,lmd=NULL,umd=lmd)
formula |
A formula with a numeric element of a data frame on the left and one or more categorical elements on the right. |
data |
A data frame containing the elements in formula. |
maxlevels |
The maximum number of levels in any categorical element. Mainly to prevent the mess caused by breaking down by a huge number of categories. |
mct |
The measure of central tendency function to use - defaults to the normal standard error. |
lmd |
The lower measure of dispersion function to use. |
umd |
The upper measure of dispersion function to use. |
hierobrk performs the breakdown of a numeric element of a data frame by one or more categorical elements. For each category and optionally subcategories, the variable on the left of the formula is summarized as specified by the functions named in num.desc.
The user should take care when specifying different summary functions. hierobarp expects a measure of central tendency as the first function and measures of dispersion as the second and third, if "error bars" are to be displayed.
A list with four elements:
mctlist |
The array produced by the function passed as the mct argument. |
lcllist |
The array produced by the function passed as the lmd argument. |
ucllist |
The array produced by the function passed as the umd argument. |
barlabels |
A list containing the unique elements of the variables on the right side of the formula (or the levels if they are factors), in the order in which they appear in the formula. These will be the default labels for the hierobarp function. |
This function is similar to brkdn in the prettyR package, but is structured to be used with the hierobarp function.
Jim Lemon
test.df<-data.frame(Age=rnorm(100,25,10), Sex=sample(c("M","F"),100,TRUE), Marital=sample(c("M","X","S","W"),100,TRUE), Employ=sample(c("FT","PT","NO"),100,TRUE)) hierobrk(formula=Age~Sex+Marital+Employ,data=test.df)