plotuv {reportRmd} | R Documentation |
Plot multiple bivariate relationships in a single plot
Description
This function is designed to accompany uvsum
as a means of
visualising the results, and uses similar syntax.
Usage
plotuv(
response,
covs,
data,
showN = FALSE,
showPoints = TRUE,
na.rm = TRUE,
response_title = NULL,
return_plotlist = FALSE,
ncol = 2,
p_margins = c(0, 0.2, 1, 0.2),
bpThreshold = 20,
mixed = TRUE
)
Arguments
response |
character vector with names of columns to use for response |
covs |
character vector with names of columns to use for covariates |
data |
dataframe containing your data |
showN |
boolean indicating whether sample sizes should be shown on the plots |
showPoints |
boolean indicating whether individual data points should be shown when n>20 in a category |
na.rm |
boolean indicating whether na values should be shown or removed |
response_title |
character value with title of the plot |
return_plotlist |
boolean indicating that the list of plots should be returned instead of a plot, useful for applying changes to the plot, see details |
ncol |
the number of columns of plots to be display in the ggarrange call, defaults to 2 |
p_margins |
sets the TRBL margins of the individual plots, defaults to c(0,0.2,1,.2) |
bpThreshold |
Default is 20, if there are fewer than 20 observations in a category then dotplots, as opposed to boxplots are shown. |
mixed |
should a mix of dotplots and boxplots be shown based on sample size? If false then all categories will be shown as either dotplots, or boxplots according the bpThreshold and the smallest category size |
Details
Plots are displayed as follows: If response is continuous For a numeric predictor scatterplot For a categorical predictor: If 20+ observations available boxplot, otherwise dotplot with median line If response is a factor For a numeric predictor: If 20+ observations available boxplot, otherwise dotplot with median line For a categorical predictor barplot Response variables are shown on the ordinate (y-axis) and covariates on the abscissa (x-axis)
Value
a list containing plots for each variable in covs
a plot object
See Also
Examples
## Run multiple univariate analyses on the pembrolizumab dataset to predict cbr and
## then visualise the relationships.
data("pembrolizumab")
rm_uvsum(data=pembrolizumab,
response='cbr',covs=c('age','sex','l_size','baseline_ctdna'))
plotuv(data=pembrolizumab, response='cbr',
covs=c('age','sex','l_size','baseline_ctdna'),showN=TRUE)