Description Usage Arguments Details Author(s) Examples
Produces bar plot and LaTex table of categorical variables vs. treatment.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | uwBarPlot(
demoData,
demoBarPlot = FALSE,
trxName = NULL,
factorName,
factorNames = NULL,
cex.names = 1,
pBeside = TRUE,
pHoriz = FALSE,
yLab = NULL,
xLab = NULL,
pTitle = NULL,
axLim = NULL,
printBarVals = TRUE,
digits = 1,
lined = TRUE,
Percent = TRUE,
barNamesLas = 1,
barNamesSeq = 1,
barNamesAngle = 0,
printPVals = TRUE,
pTest = c("wilcox", "fisher", "chisq"),
abbrevN = 1,
pairwise = TRUE,
pAdjust = NULL,
trxControl = NULL,
pExclude = NULL,
pInclude = list(list(NULL, NULL)),
pStrWrap = FALSE,
pValCex = 0.7,
titleCex = 1,
Legend = TRUE,
LegendLoc = "topright",
LegendCex = 0.8,
LatexFileName = NULL,
LatexCaption = NULL,
trxColname = NULL,
...
)
|
demoData |
data frame containing 1 or 2 factor columns |
demoBarPlot |
(logical) TRUE plots a bar plot like the old uwDemoBarPlot function in which each factorName level is broken down by trxName. FALSE plots a traditional uwBarPlot in which each trxName level is broken down by factorName |
trxName |
(string) Name of the demoData column containing the treatment factor. If NULL then bar plot for just factorName is given |
factorName |
(string) Name of the demoData column containing the categorical factor. |
factorNames |
Vector of names to be applied to the factor column. Be careful with order. Table is created with factorName levels, which can then be switched if factorNames is not NULL. Length must be the same as number of levels of factorName. If factorName is ordered follow that ordering when listing the order of factorNames, if not then follow alphabetic ordering of levels of factorName. |
cex.names |
(uwBar) expansion factor for axis names (bar levels) |
pBeside |
(uwBar)(logical) If TRUE the graph is a stacked bar plot. |
pHoriz |
(uwBar)(logical) If TRUE the bars are horizontal to the x-axis. |
yLab |
(uwBar)(string) Label of y-axis. |
xLab |
(uwBar)(string) Label of x-axis. |
pTitle |
(string) Title of the graph. |
axLim |
(c(start, finish)) Gives limit of axis for bar heights. x-axis if pHoriz=TRUE, y-axis if pHoriz=FALSE |
printBarVals |
(uwBar)(logical) If TRUE the value represented by each bar is printed over the top of the bar. Only if pBeside=TRUE |
digits |
(positive numeric) Indicates number of decimals to be reported in the graph and in the table |
lined |
(uwBar)(logical) TRUE has levels of bars alternate between solid and lined bars. |
Percent |
(logical) If TRUE the graphs show percentages of patients instead of counts. |
barNamesLas |
(0,1,2,or 3). Changes the verticality of the treatment names for bar names and numeric axis. 1 and 2 are best for reporting |
barNamesSeq |
(uwBar)(integer) Number indicating which bar labels to print. This number is given as the "by" attribute to seq(). So every barNameSeq would be printed. Default is 1, which will print all bar labels. Helpful when bar labels overlap when printing all of them. |
barNamesAngle |
(uwBar)(integer) Number between 0 and 360 indicating how the margin names should be rotated. Useful when margin names are long strings so you can angle them to all be seen |
printPVals |
(uwPVals)(logical) If TRUE, p-values indicated by the attributes for uwPVals are printed in the margin of the plot. |
pTest |
(uwPVals)(printPVals=TRUE) Chose type of comparison test |
abbrevN |
(uwPVals)(integer) indicating how many letters should abbreviation of the treatments levels be when reported in margins. |
pairwise |
(uwPVals)(logical) If TRUE, pairwise comparisons should be made between treatment levels. If FALSE, multi-level test occurs between all levels of the treatment (i.e. ANOVA) |
pAdjust |
(uwPVals)(pairwise=TRUE) NULL for none, "h" for "holm", or "b" for "bonferroni". P-value adjustment methods. |
trxControl |
(uwPVals)(pairwise=TRUE) If NULL, all two-way tests will be examined. If a treatment level is indicated here as the control level, then only two-way comparisons with the control and non-control levels will be made. |
pExclude |
(uwPVals)(pairwise=TRUE) If trxControl is NULL then this should be a vector of treatment levels, looked at two at a time, that indicate that the p-value for that contrast should NOT be reported. Suppose the treatment levels are A,B,C,D and you do not want the comparisons for B.C., B.D., and C.D.. pExclude should look like this. pExclude=c("B","C","B","D","C","D"). If trxControl is defined then this should be a vector of non-control treatment levels that will be looked at one at a time and that non-control's contrast will NOT be reported |
pInclude |
(uwPVals)(pairwise=TRUE) Gives the user the ability to specify which contrasts they would like to get p-values for. The ability to combine treatment levels for a contrast is possible. See help(uwPVals) for more details. |
pStrWrap |
(logical) If TRUE, creates two rows of p-value string on the top margin instead of one. Useful for many reported p-values. |
pValCex |
Number between 0 and 1. Size of the p-value font in the top margin. |
titleCex |
(figureBox) Number between 0 and 1. Size of the title font |
Legend |
(uwBar)(logical) If TRUE, puts a legend in the graph |
LegendLoc |
(uwBar)(string)(Legend=TRUE). Gives the location in the graph where the legend will be located. One of these must be given. "topleft", "top", "topright", "left", "center", "right", "bottomleft", "bottom", or "bottomright" |
LegendCex |
Size of legend. Number between 0 and 1, 1=full size, 0=no size. |
LatexFileName |
(uwLatex)(string) Giving the folder and file(ending in .tex) for the LaTeX table to be saved. If NULL, table will be printed, but not saved. |
LatexCaption |
(uwLatex)(string) Giving the caption for each LaTeX table. If NULL, defaults to pTitle |
trxColname |
(uwLatex)(string) Name for first column, which is like a title for the rows. The default is trxName if !is.null(trxName), or factorName if is.null(trxName). |
... |
Any other argument that can be passed to uwLatex() |
Bar graph for one or two categorical variables. trxName is on the outside of the graph and factorName is on the inside of the graph. uwBar is used to create the bar plot. uwPVals calculates the p-values. uwLatex is used to create a corresponding LaTeX table.
Additional Functions Required: uwLatex(), uwPVals(), uwBar(), and figureBox()
factorName must be a column name in demoData and a factor or able to be converted to a factor trxName, if given, must be a column name in demoData and a factor or able to be converted to a factor.
It is recommended that factorName is an ordered vector especially when it is an ordinal variable. This will ensure proper order in the graph and table.
With printPVals==TRUE, see documentation for uwPVals() to see how to use pTest, pairwise, trxControl, and pExclude effectively
With printPVals==TRUE and trxControl=NULL, all two-way comparisons are reported for the levels of trxName. No adjustments are made to the p-values to account for the multiple testing. pAdjust can be utilized to make p-value adjustments.
University of Wisconsin-Madison Biostatistics and Medical Informatics Department, Scott Hetzel M.S.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | TRT <- rep(c("A", "B", "C"), 30)
AE <- ordered(
sample(c("None", "Mild", "Moderate", "Severe"), 90, replace = TRUE),
c("None", "Mild", "Moderate", "Severe")
)
data <- data.frame(TRT, AE)
layout(matrix(c(1, 1, 2, 2, 3, 3, 4, 4), nrow = 2, byrow = TRUE))
uwBarPlot(
demoData = data, trxName = NULL, factorName = "AE", Legend = TRUE, demoBarPlot = FALSE,
pHoriz = TRUE, pBeside = TRUE, xLab = "Number of Subjects", pTitle = "Adverse Events",
digits = 1, barNamesAngle = 60, cex.names = 0.8, lined = FALSE, Percent = FALSE,
barNamesLas = 1, barNamesSeq = 1, printPVals = TRUE, pTest = "f", pValCex = 0.6,
LatexFileName = NULL, LegendLoc = "topright"
)
uwBarPlot(
demoData = data, trxName = "TRT", factorName = "AE", Legend = TRUE, demoBarPlot = TRUE,
pHoriz = TRUE, xLab = "Number of Subjects", pTitle = "Adverse Events", digits = 1,
barNamesAngle = 0, lined = FALSE, Percent = FALSE, barNamesLas = 0, barNamesSeq = 1,
printPVals = TRUE, pTest = "f", pValCex = 0.6, LatexFileName = NULL, LegendLoc = "topright",
pStrWrap = TRUE
)
uwBarPlot(
demoData = data, trxName = "TRT", factorName = "AE", Legend = TRUE, demoBarPlot = FALSE,
pHoriz = FALSE, yLab = "Percent of Subjects", pTitle = "Adverse Events", digits = 1,
barNamesAngle = 0, lined = FALSE, Percent = TRUE, barNamesLas = 1, barNamesSeq = 1,
printPVals = TRUE, pTest = "f", pValCex = 0.6, LatexFileName = NULL, LegendLoc = "topleft"
)
uwBarPlot(
demoData = data, trxName = "TRT", factorName = "AE", Legend = TRUE, demoBarPlot = TRUE,
pHoriz = FALSE, yLab = "Percent of Subjects", pTitle = "Adverse Events", digits = 1,
barNamesAngle = 45, lined = TRUE, Percent = TRUE, barNamesLas = 1, barNamesSeq = 1,
printPVals = TRUE, pTest = "f", pValCex = 0.6,
LatexFileName = NULL, LegendLoc = "topleft"
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.