View source: R/UBStats_Main_Visible_ALL_202406.R
summaries.plot.x | R Documentation |
summaries.plot.x()
plots location statistics for a
numeric vector conditioned to the levels of one or more variables.
summaries.plot.x(
x,
stats = "mean",
plot.type = "bars",
conf.level = 0.95,
by1,
by2,
breaks.by1,
interval.by1 = FALSE,
breaks.by2,
interval.by2 = FALSE,
adj.breaks = TRUE,
bw = FALSE,
color = NULL,
legend = TRUE,
use.scientific = FALSE,
data,
...
)
x |
An unquoted string identifying a numerical variable whose
tendency measures have to be graphically displayed.
|
stats |
A single character specifying the conditioned
tendency measure/s to
display in the plot. The available options are |
plot.type |
A single character specifying the type of plot
used to compare the requested measures conditioned to the levels
of one variable,
|
conf.level |
A number between 0 and 1 indicating the
confidence level of the intervals for the conditional means
when |
by1 , by2 |
Unquoted strings identifying variables
(typically taking few values/levels) used to build conditional
summaries, that can be defined same way as |
breaks.by1 , breaks.by2 |
Allow classifying the variables
|
interval.by1 , interval.by2 |
Logical values indicating
whether |
adj.breaks |
Logical value indicating whether the endpoints of
intervals of the numerical variables |
bw |
Logical value indicating whether plots should be colored
in scale of greys ( |
color |
Optional string vector to specify colors
to use in the plot rather than a standard palette
( |
legend |
Logical value indicating whether a legend should be displayed
in the plot ( |
use.scientific |
Logical value indicating whether numbers on
axes should be displayed using scientific notation
( |
data |
An optional data frame containing |
... |
Additional arguments to be passed to low level functions. |
A table (converted to dataframe) reporting the requested statistics conditioned to the levels of the specified layers.
Raffaella Piccarreta raffaella.piccarreta@unibocconi.it
distr.summary.x()
for tabulating summary
measures of a univariate distribution.
distr.plot.x()
for plotting a univariate
distribution.
distr.table.x()
for tabulating a univariate
distribution.
data(MktDATA, package = "UBStats")
# Means (and their CI) or medians by a single variable
# - Barplot of means (default) by a character
summaries.plot.x(x = TotVal, stats = "mean",
by1 = Gender, data = MktDATA)
# - Barplot of medians by a numerical variable
# classified into intervals: user-defined color
summaries.plot.x(x = TotVal, stats = "median",
by1 = AOV, breaks.by1 = 5,
color = "purple", data = MktDATA)
# - Lineplot of means and their CI by a variable
# measured in classes
summaries.plot.x(x = TotVal,
stats = "ci.mean", plot.type = "lines",
by1 = Income.S, interval.by1 = TRUE,
data = MktDATA)
# - Barplot of means and their CI by a
# numerical variable; change the confidence level
summaries.plot.x(x = TotVal,
stats = "ci.mean", conf.level = 0.90,
plot.type = "bars",
by1 = NWeb_Purch, data = MktDATA)
# - Note: no plot built for a variable with
# too many levels (>20)
# summaries.plot.x(x = TotVal,
# stats = "ci.mean", plot.type = "lines",
# by1 = AOV, data = MktDATA)
# Quantiles by a single variable
# - Only lines plots allowed for quantiles
summaries.plot.x(x = Baseline,
stats = "deciles", plot.type = "lines",
by1 = NDeals, data = MktDATA)
summaries.plot.x(x = Baseline,
stats = "quartiles", plot.type = "lines",
by1 = Marital_Status, data = MktDATA)
# Means and medians by two variables
# - Default: only lines allowed
summaries.plot.x(x = TotVal, stats = "mean",
by1 = Education, by2 = Kids,
data = MktDATA)
summaries.plot.x(x = TotVal, stats = "median",
by1 = Income.S, by2 = Gender,
interval.by1 = TRUE,
data = MktDATA)
summaries.plot.x(x = Baseline, stats = "mean",
by1 = CustClass, by2 = AOV,
breaks.by2 = 5, data = MktDATA)
# - "ci.mean" not allowed with two layers
CustClass_Kids<-paste0(MktDATA$CustClass,"-",MktDATA$Kids)
summaries.plot.x(x = Baseline, stats = "ci.mean",
conf.level = 0.99, by1 = CustClass_Kids,
color = "gold", data = MktDATA)
# Arguments adj.breaks and use.scientific
# Variables with a very wide range
LargeX<-MktDATA$TotVal*1000000
LargeBY<-MktDATA$AOV*5000000
# - Default: no scientific notation
summaries.plot.x(LargeX, plot.type = "bars",
by1=LargeBY, breaks.by1 = 5, data = MktDATA)
# - Scientific notation for summaries (axes)
summaries.plot.x(LargeX, plot.type = "lines",
by1=LargeBY, breaks.by1 = 5,
use.scientific = TRUE, data = MktDATA)
# - Scientific notation for intervals endpoints
summaries.plot.x(LargeX, stats = "ci.mean",
plot.type = "lines",
by1=LargeBY, breaks.by1 = 5,
adj.breaks = FALSE, data = MktDATA)
# - Scientific notation for intervals endpoints and summaries
summaries.plot.x(LargeX, stats = "quartiles",
plot.type = "lines",
by1=LargeBY, breaks.by1 = 5,
adj.breaks = FALSE, use.scientific = TRUE,
data = MktDATA)
# Output the table with the requested summaries
Out_TotVal<-summaries.plot.x(x = TotVal, stats = "ci.mean",
by1 = Education, data = MktDATA)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.