View source: R/UBStats_Main_Visible_ALL_202406.R
distr.summary.x | R Documentation |
distr.summary.x()
computes summary statistics of a vector or a factor.
distr.summary.x(
x,
stats = c("summary"),
by1,
by2,
breaks.by1,
interval.by1 = FALSE,
breaks.by2,
interval.by2 = FALSE,
adj.breaks = TRUE,
digits = 2,
f.digits = 4,
force.digits = FALSE,
use.scientific = FALSE,
data,
...
)
x |
An unquoted string identifying the variable whose
distribution has to be summarized. |
stats |
A character vector specifying the summary statistics to compute (more summaries can be specified). Specific types of summaries can be requested with the following options:
It is also possible to request the following statistics:
|
by1 , by2 |
Unquoted strings identifying optional 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 |
digits , f.digits |
Integer values specifying the number of
decimals used to round respectively summary statistics
(default: |
force.digits |
Logical value indicating whether the
requested summaries should be forcedly rounded to the number of decimals
specified in |
use.scientific |
Logical value indicating whether numbers
in tables should be displayed using
scientific notation ( |
data |
An optional data frame containing |
... |
Additional arguments to be passed to low level functions. |
A list whose elements are tables
(converted to dataframes) with the requested summaries, possibly
conditioned to by1
and/or by2
. The values taken
by the conditioning variables are arranged in standard
order (logical, alphabetical or numerical order for vectors,
order of levels for factors, ordered intervals for classified
variables or for variables measured in classes).
Raffaella Piccarreta raffaella.piccarreta@unibocconi.it
summaries.plot.x()
to graphically display
conditioned tendency summaries of a univariate distribution.
distr.table.x()
for tabulating a univariate
distribution.
distr.plot.x()
for plotting a univariate
distribution.
data(MktDATA, package = "UBStats")
# Marginal summaries
# - Numerical variable: Default summaries
distr.summary.x(x = AOV, data = MktDATA)
# - Numerical variable: More summaries
distr.summary.x(x = AOV,
stats = c("central","dispersion","fivenum"),
data = MktDATA)
distr.summary.x(x = AOV, stats = c("mode","mean","sd","cv","fivenum"),
data = MktDATA)
# - Character or factor (only proper statistics calculated)
distr.summary.x(x = LikeMost, stats = c("mode","mean","sd","cv","fivenum"),
data = MktDATA)
distr.summary.x(x = Education, stats = c("mode","mean","sd","cv","fivenum"),
data = MktDATA)
# Measures conditioned to a single variable
# - Numerical variable by a character vector
distr.summary.x(x = TotVal,
stats = c("p5","p10","p25","p50","p75","p90","p95"),
by1 = Gender, digits = 1, data = MktDATA)
# - Numerical variable by a numerical variable
# classified into intervals
distr.summary.x(x = TotVal,
stats = c("central","dispersion"),
by1 = AOV, breaks.by1 = 5,
digits = 1, data = MktDATA)
# - Numerical variable by a variable measured in classes
distr.summary.x(x = TotVal,
stats = c("central","dispersion"),
by1 = Income.S,
interval.by1 = TRUE,
digits = 1, data = MktDATA)
# Measures conditioned to two variables
distr.summary.x(x = TotVal, stats = "fivenumbers",
by1 = Gender, by2 = Kids, data = MktDATA)
distr.summary.x(x = TotVal, stats = "fivenumbers",
by1 = Income.S, by2 = Gender,
interval.by1 = TRUE, data = MktDATA)
distr.summary.x(x = TotVal, stats = "fivenumbers",
by1 = Gender, by2 = AOV,
breaks.by2 = 5, 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
distr.summary.x(LargeX, by1=LargeBY, breaks.by1 = 5,
data = MktDATA)
# - Scientific notation for summaries
distr.summary.x(LargeX, by1=LargeBY, breaks.by1 = 5,
use.scientific = TRUE, data = MktDATA)
# - Scientific notation for intervals endpoints
distr.summary.x(LargeX, by1=LargeBY, breaks.by1 = 5,
adj.breaks = FALSE, data = MktDATA)
# - Scientific notation for intervals endpoints and summaries
distr.summary.x(LargeX, by1=LargeBY, breaks.by1 = 5,
adj.breaks = FALSE, use.scientific = TRUE,
data = MktDATA)
# Output the list with the requested summaries
Out_TotVal<-distr.summary.x(x = TotVal,
by1 = Income.S, by2 = Gender,
interval.by1 = TRUE,
stats = c("central","fivenum","dispersion"),
data = MktDATA)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.