Description Usage Arguments Details Author(s) See Also Examples
View source: R/uwLeveledBoxPlot.R
This function will produce a graphic and statistical testing for a numeric variable when stratified by two factor variables. Generally one of the factor variables is considered the treatment variable. Also produced is code for a corresponding LaTeX table.
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 40 41 42 43 | uwLeveledBoxPlot(
allData,
trxName,
metricName,
lowfactName,
hifactName = NULL,
delta = FALSE,
deltaPct = FALSE,
baseLevel = NULL,
idName = NULL,
LatexFileName = NULL,
LatexCaption = NULL,
lowfacttableName = "",
hifacttableName = "",
showTab = FALSE,
pTitle = NULL,
yLab = NULL,
yLim = NULL,
plotMean = FALSE,
pOutliers = FALSE,
lWhisker = 0.05,
hWhisker = 0.95,
lHinge = 0.25,
hHinge = 0.75,
boxWex = 0.75,
LabelCex = 0.7,
Legend = FALSE,
LegendLoc = "topright",
LegendCex = 0.7,
printPVals = TRUE,
PVinTableOnly = FALSE,
PValCex = 0.6,
pTest = c("wilcox", "t.test"),
abbrevN = 1,
pairwise = TRUE,
pAdjust = NULL,
trxControl = NULL,
pExclude = NULL,
pInclude = list(list(NULL, NULL)),
Ropen = FALSE,
numDec = 2,
...
)
|
allData |
Data frame in R that contains all of the variables |
trxName |
String. Name of the treatment variable in allData |
metricName |
String. Name of the numeric variable in allData that will be represented by boxes |
lowfactName |
String. Name of the low-level factor variable in allData that will be used to stratify. Make the factor an ordered factor if order matters in the reporting. |
hifactName |
String. Name of the upper-level factor variable in allData that will be used to stratify first, and then stratify on lowfactName. |
delta |
Logical. TRUE looks at differences from baseLevel and other levels of hifactName or lowfactName is no hifactName is given |
deltaPct |
Logical. TRUE gives percentage change from baseLevel. delta must also be TRUE |
baseLevel |
String. Level in hifactName or lowfactName if no hifactName is given that is considered the baseline level |
idName |
String. Variable in allData that gives patient identifiers. Only necessary if delta=TRUE |
LatexFileName |
String. Giving the file path and name, ending in .tex, where the LaTeX code for the table should be saved. If NULL, table is printed in the R session but not saved. |
LatexCaption |
uwLatex, Caption for Latex table |
lowfacttableName |
String to be given to the lowfactName in the LaTeX table |
hifacttableName |
String to be given to the hifactName in the LaTeX table |
showTab |
Logical. TRUE -> Displays the compiled LaTeX table using dvix |
pTitle |
String. Title of the Plot and caption of the LaTeX table |
yLab |
String. Label for the y-axis. |
yLim |
Limits of y-axix. In the form: c(start,finish) |
plotMean |
Logical. TRUE -> A line is plotted in the box plots showing the mean value. A point is always plotted showing the median value. |
pOutliers |
Logical. TRUE -> Show points outside of whiskers |
lWhisker |
Lower whisker level. Default is .05 for 5th percentile |
hWhisker |
Upper whisker level. Default is .95 for 95th percentile |
lHinge |
Lower level of box. Default is .25 for 25th percentile |
hHinge |
Upper level of box. Default is .75 for 75th percentile |
boxWex |
Number for width of boxes |
LabelCex |
Numeric. Gives magnification level of the labels in the x-axis. Less than 1 shrinks them, greater than 1 expands them. |
Legend |
Logical. TRUE puts a legend of the trxName levels in the plot and removes the labeling in the x-axis for trxName levels |
LegendLoc |
Location of the legend if Legend=TRUE, see help(legend) |
LegendCex |
Numeric. Gives magnification level of the legend |
printPVals |
Logical. TRUE -> Prints p-values on the top of the graph and adds them to the LaTeX table |
PVinTableOnly |
Logical. TRUE Suppresses the printing of p-values in the top margin of the graph, but they are still printed in the LaTeX table. Useful when p-values are hard to read in the margin |
PValCex |
Numeric. Gives magnification level of the p-values in the top margin |
pTest |
printPVals must be TRUE. Chose type of comparison test |
abbrevN |
Whole number indicating how many letters should abbreviation of the treatments levels should be. |
pairwise |
(logical) TRUE pairwise comparisons should be made between treatment levels. FALSE multi-level test occurs between all levels of the treatment |
pAdjust |
NULL for none, "h" for "holm", or "b" for "bonferroni". P-value adjustment methods. See uwPVals for more information. |
trxControl |
Must be defined if pairwise=TRUE. A treatment level is indicated here as the control level, two-way comparisons with the control and non-controls will then be made. |
pExclude |
only applies if pairwise=TRUE. 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 |
List specifying contrasts want to be examined. This is most useful when wanting to combine treatment levels together. See uwPVals for more details |
Ropen |
Logical. TRUE collapses data across all treatment arms. |
numDec |
Numeric from 0 to 20 indicating number of decimals to be reported in the tables |
... |
Any other argument that can be passed to uwLatex other than mat, file, or col.just which are already set |
Special Functions used in uwLeveledBoxPlot: uwPVals and uwLatex
Plotting points in the boxes represent the median value. A line would represent the mean if plotMean=TRUE.
University of Wisconsin-Madison Biostatistics and Medical Informatics Department, Scott Hetzel M.S. and Frontier Science and Technology Research Foundation, Patrick Lenon
uwBoxPlot(), uwLatex()
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | trt1 <- rep(rep(c("A", "B", "C"), 120), 3)
fctr1 <- as.factor(rep(c(rep("Female", 180), rep("Male", 180)), 3))
mtrc1 <- rnorm(360 * 3, 10, 4)
upfct <- c(rep("Baseline", 360), rep("Week 12", 360), rep("Week 24", 360))
ids <- as.character(c(1:360, 1:360, 1:360))
dat1 <- data.frame(trt1, fctr1, mtrc1, upfct, ids)
lyt <- layout(matrix(c(1, 1, 2, 2, 3, 3), nrow = 3, byrow = TRUE))
uwLeveledBoxPlot(
allData = dat1,
trxName = "trt1",
metricName = "mtrc1",
lowfactName = "fctr1",
hifactName = "upfct",
delta = FALSE,
baseLevel = "Baseline",
idName = "ids",
LatexFileName = NULL,
showTab = FALSE,
Legend = FALSE,
pTitle = "Example of uwLeveledBoxPlot",
yLab = "Random Normal",
plotMean = TRUE, pOutliers = FALSE,
lWhisker = .05, hWhisker = .95,
lHinge = .25, hHinge = .75,
boxWex = 0.75,
printPVals = TRUE,
PVinTableOnly = FALSE,
PValCex = 0.5,
Ropen = FALSE,
pTest = "t",
abbrevN = 1,
pairwise = TRUE,
trxControl = NULL,
pExclude = NULL,
yLim = NULL
)
uwLeveledBoxPlot(
allData = dat1,
trxName = "trt1",
metricName = "mtrc1",
lowfactName = "fctr1",
hifactName = "upfct",
delta = TRUE,
deltaPct = FALSE,
baseLevel = "Baseline",
idName = "ids",
LatexFileName = NULL,
showTab = FALSE,
Legend = TRUE,
LegendLoc = "topleft",
pTitle = "Example of uwLeveledBoxPlot with delta=TRUE",
yLab = "Random Normal",
plotMean = FALSE, pOutliers = FALSE,
lWhisker = .05, hWhisker = .95,
lHinge = .25, hHinge = .75,
boxWex = 0.75,
printPVals = TRUE,
PVinTableOnly = FALSE,
PValCex = 0.5,
Ropen = FALSE,
pTest = "w",
abbrevN = 1,
pairwise = TRUE,
trxControl = NULL,
pExclude = NULL,
pInclude = list(list(c("A", "B"), "C"), list("A", c("B", "C")), list("A", "C")),
yLim = NULL
)
uwLeveledBoxPlot(
allData = dat1,
trxName = "trt1",
metricName = "mtrc1",
lowfactName = "fctr1",
hifactName = "upfct",
delta = TRUE,
deltaPct = TRUE,
baseLevel = "Baseline",
idName = "ids",
LatexFileName = NULL,
showTab = FALSE,
Legend = TRUE,
LegendLoc = "topleft",
pTitle = "Example of uwLeveledBoxPlot with deltaPct=TRUE",
yLab = "Random Normal",
plotMean = FALSE, pOutliers = FALSE,
lWhisker = .05, hWhisker = .95,
lHinge = .25, hHinge = .75,
boxWex = 0.75,
printPVals = TRUE,
PVinTableOnly = FALSE,
PValCex = 0.5,
Ropen = FALSE,
pTest = "w",
abbrevN = 1,
pairwise = TRUE,
trxControl = NULL,
pExclude = NULL,
pInclude = list(list(c("A", "B"), "C"), list("A", c("B", "C")), list("A", "C")),
yLim = NULL
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.