View source: R/UBStats_Main_Visible_ALL_202406.R
distr.table.xy | R Documentation |
distr.table.xy()
displays tables of joint or conditional
distributions.
distr.table.xy(
x,
y,
freq = "counts",
freq.type = "joint",
total = TRUE,
breaks.x,
breaks.y,
adj.breaks = TRUE,
interval.x = FALSE,
interval.y = FALSE,
f.digits = 2,
p.digits = 0,
force.digits = FALSE,
data,
...
)
x , y |
Unquoted strings identifying the variables whose joint
distribution has to be analysed. |
freq |
A character vector specifying the set of frequencies
to be displayed (more options are allowed). Allowed options
(possibly abbreviated) are |
freq.type |
A character vector specifying the types of
frequencies to be displayed (more types are allowed).
Allowed options are |
total |
Logical value indicating whether the sum of the requested
frequencies should be added to the table; default to |
breaks.x , breaks.y |
Allow to classify the variables |
adj.breaks |
Logical value indicating whether the endpoints of
intervals of a numerical variable ( |
interval.x , interval.y |
Logical values indicating whether
|
f.digits , p.digits |
Integer values specifying the number of
decimals used to round respectively proportions
(default: |
force.digits |
Logical value indicating whether proportions and
percentages should be forcedly rounded to the number of decimals specified in
|
data |
An optional data frame containing |
... |
Additional arguments to be passed to low level functions. |
A list whose elements are the requested tables (converted to dataframes) listing the values taken by the two variables 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) and the specified joint or conditional types of frequencies.
Raffaella Piccarreta raffaella.piccarreta@unibocconi.it
distr.plot.xy()
for plotting a bivariate
distribution.
distr.table.x()
for tabulating a univariate
distribution.
distr.plot.x()
for plotting a univariate
distribution.
data(MktDATA, package = "UBStats")
# Character vectors, factors, and discrete numeric vectors
# - Default: joint counts
distr.table.xy(LikeMost, Children, data = MktDATA)
# - Joint and conditional distribution of x|y
# counts and proportions, no totals
distr.table.xy(LikeMost, Education, freq = c("counts","Prop"),
freq.type = c("joint","x|y"), total = FALSE,
data = MktDATA)
# - Joint and conditional row and column distributions (%)
distr.table.xy(CustClass, Children, freq = "Percentages",
freq.type = c("joint","row","column"),
data = MktDATA)
# Numerical variables classified or measured in classes
# - A numerical variable classified into intervals
# and a factor
distr.table.xy(CustClass, TotPurch,
breaks.y = c(0,5,10,15,20,35),
freq = c("Counts","Prop"), freq.type = "y|x",
data = MktDATA)
# - Two numerical variables, one measured in classes
# and the other classified into intervals
distr.table.xy(Income.S, TotPurch, interval.x = TRUE,
breaks.y = c(0,5,10,15,20,35),
freq = c("Counts","Prop"),
freq.type = c("row","col"), data = MktDATA)
# Argument force.digits
# - Default: manages possible excess of rounding
distr.table.xy(CustClass, Children, freq = "Percentages",
freq.type = c("x|y"),data = MktDATA)
# - Force to the required rounding
distr.table.xy(CustClass, Children, freq = "Percentages",
freq.type = c("x|y"),
force.digits = TRUE, data = MktDATA)
# Output the list with the requested tables
tables.xy<-distr.table.xy(Income.S, TotPurch,
interval.x = TRUE,
breaks.y = c(0,5,10,15,20,35),
freq = c("Counts","Prop"),
freq.type = c("joint","row","col"),
data = MktDATA)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.