Package {ggInterval}


Type: Package
Title: Visualizing Interval-Valued Data Using 'ggplot2'
Version: 0.2.6
Date: 2026-11-18
Author: Bo-Syue Jiang [aut], Han-Ming Wu [cre]
Maintainer: Han-Ming Wu <wuhm@g.nccu.edu.tw>
Description: Extends 'ggplot2' for visualizing interval-valued data with scatter plots, histograms, index plots, boxplots, radar plots, PCA displays, and correlation heatmaps. The package also converts classical data tables into interval-valued data using clustering algorithms or user-defined groupings.
Depends: ggplot2, R (≥ 4.4.0), tidyverse, RSDA
Suggests: testthat (≥ 3.0.0), knitr, rmarkdown, data.table, HistDAWass, MAINT.Data, TTR, MASS
Imports: rlang, R6, dplyr, tidyr, gridExtra, gtools, stringr, prodlim, ggforce, ggpubr, ggthemes, tibble, magrittr, vctrs
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.3
VignetteBuilder: knitr
Config/testthat/edition: 3
URL: https://github.com/hanmingwu1103/ggInterval, https://CRAN.R-project.org/package=ggInterval
BugReports: https://github.com/hanmingwu1103/ggInterval/issues
NeedsCompilation: no
Packaged: 2026-11-18 07:19:48 UTC; User
Repository: CRAN
Date/Publication: 2026-11-18 08:10:02 UTC

Cardiological data example

Description

Cardiological interval data example.

Usage

data(Cardiological)

Format

An object of class symbolic_tbl (inherits from tbl_df, tbl, data.frame) with 11 rows and 3 columns.

Source

Adapted from RSDA::Cardiological; see https://CRAN.R-project.org/package=RSDA.

References

Billard, Lynne and Diday, Edwin (2006). Symbolic Data Analysis: Conceptual Statistics and Data Mining. Chichester, UK: John Wiley and Sons.

Examples

data(Cardiological)
ggInterval_indexplot(Cardiological, aes(x = Syst))

Cardiological data example

Description

Cardiological interval data example.

Usage

data(Cardiological2)

Format

An object of class symbolic_tbl (inherits from tbl_df, tbl, data.frame) with 15 rows and 3 columns.

Source

Adapted from RSDA::Cardiological2; see https://CRAN.R-project.org/package=RSDA.

References

Billard, Lynne and Diday, Edwin (2006). Symbolic Data Analysis: Conceptual Statistics and Data Mining. Chichester, UK: John Wiley and Sons.

Examples

data(Cardiological2)
ggInterval_indexplot(Cardiological2, aes(x = Syst))

Environment data example

Description

Environmental-questionnaire data with 14 symbolic objects and 17 variables: 13 interval variables (CONTROL through VEHICLE) and four modal variables (URBANICITY, INCOMELEVEL, EDUCATION, REGIONDEVELOPME).

Usage

data(Environment)

Format

An object of class symbolic_tbl (inherits from tbl_df, tbl, data.frame) with 14 rows and 17 columns.

Details

Stored values match the SODAS example distributed with Umbleja, Ichino and Yaguchi (2020). Source object identifiers 1241, 1242, 1441, 1442, 1641, 1642, 1741, 2241, 2242, 2441, 2442, 2641, 2642, 2741 correspond in order to rows 1–14. Modal categories are numeric codes without a codebook. Since version 0.2.6 the INCOMELEVEL category labels follow the order of the SODAS source files, 25, 75, 50, 90, 100. Earlier versions listed the labels as 25, 50, 75, 90, 100 while storing the proportions in the source order, so the labels 50 and 75 were interchanged; the proportions are unchanged.

References

Umbleja, K., Ichino, M. and Yaguchi, H. (2020). Improving symbolic data visualization for pattern recognition and knowledge discovery. Visual Informatics, 4(1), 23–31. doi:10.1016/j.visinf.2019.12.003.

Examples

data(Environment)
ggInterval_radarplot(Environment,
 plotPartial = 2,
 showLegend = FALSE,
 base_circle = TRUE,
 base_lty = 2,
 addText = FALSE)

RSDA object to symbolic object for ggplot

Description

It will be a good way to unify all symbolic data object in R that collects all useful symbolic analysis tools such like RSDA into the same class for management. In this way, user who wants to do some study in symbolic data will be more convenient for searching packages.Thus,RSDA2sym collecting RSDA object into ggInterval object will do for plot(ggplot) and RSDA's analysis.

Usage

RSDA2sym(data=NULL,rawData=NULL)

Arguments

data

an interval data, which may transfrom by RSDA::classic.to.sym .Note:data is a necessary parameter,and must have symbolic_tbl class.

rawData

rawData, which can be transformed to interval data, must be a data frame and match to data.

Value

Return an object of class "ggInterval", which has interval-valued data and related outputs as follows.

#'

Examples

r<-ggInterval::Cardiological
mySym<-RSDA2sym(r)
mySym$intervalData


abalone.i data example

Description

abalone.i interval data example.

Usage

data(abalone.i)

Format

An object of class data.frame (inherits from symbolic_tbl) with 24 rows and 7 columns.

Source

Adapted from MAINT.Data::AbaloneIdt; the underlying Abalone data are from the UCI Machine Learning Repository.

Examples

data(abalone.i)
ggInterval_indexplot(abalone.i, aes(x = Length))

blood.i data example

Description

blood.i interval data example.

Usage

data(blood.i)

Format

An object of class tbl_df (inherits from tbl, data.frame, symbolic_tbl) with 14 rows and 3 columns.

Source

Adapted from HistDAWass::BLOOD; see https://CRAN.R-project.org/package=HistDAWass.

References

Billard, Lynne and Diday, Edwin (2006). Symbolic Data Analysis: Conceptual Statistics and Data Mining. Chichester, UK: John Wiley and Sons.

Examples

data(blood.i)
ggInterval_MMplot(blood.i, aes(x = Hematocrit))

Convert classical data frame into a symbolic data.

Description

A function for converting a classical data, which may present as a data frame or a matrix with one entry one value, into a symbolic data object, which is represented as an interval or a set in an entry. Object after converting is ggInterval class containing interval data and raw data(if it exist) and typically statistics.

Usage

classic2sym(data=NULL,groupby = "kmeans",k=5,minData=NULL,maxData=NULL,
modalData = NULL)

Arguments

data

A classical data frame that you want to be converted into interval-valued data

groupby

A way to aggregate. It can be either a clustering method or a variable name which exist in input data (necessary factor type) . Default "kmeans".

k

A number of group,which is used by clustering. Default k = 5.

minData

if choose groupby parameter as 'customize',user need to define which data is min data or max data.

maxData

if choose groupby parameter as 'customize',user need to define which data is min data or max data.

modalData

list, each cell of list contain a set of column index of its modal multi-valued data of the input data. the value of it is a proportion presentation, and sum of each row in these column must be equal to 1. ex 0,1,0 or 0.2,0.3,0.5. the input type of modalData for example is modalData[[1]] = c(2, 3), modalData[[2]] = c(7:10), that 2, 3, 7, 8, 9, 10 columns are modal type of the data. Note: the option is only valid when groupby == "customize".

Value

classic2sym returns an object of class "ggInterval",which has interval-valued data and related outputs as follows.

Examples

#classical data to symbolic data
classic2sym(iris)
classic2sym(mtcars, groupby = "kmeans", k = 10)
classic2sym(iris, groupby = "hclust", k = 7)
classic2sym(iris, groupby = "Species")

x1<-runif(10, -30, -10)
y1<-runif(10, -10, 30)
x2<-runif(10, -5, 5)
y2<-runif(10, 10, 50)
x3<-runif(10, -50, 30)
y3<-runif(10, 31, 60)

d<-data.frame(min1=x1,max1=y1,min2=x2,max2=y2,min3=x3,max3=y3)
classic2sym(d,groupby="customize",minData=d[,c(1,3,5)],maxData=d[,c(2,4,6)])
classic2sym(d,groupby="customize",minData=d$min1,maxData=d$min2)


#example for build modal data
#for the first modal data proportion
a1 <- runif(10, 0,0.4) %>% round(digits = 1)
a2 <- runif(10, 0,0.4) %>% round(digits = 1)

#for the second modal data proportion
b1 <- runif(10, 0,0.4) %>% round(digits = 1)
b2 <- runif(10, 0,0.4) %>% round(digits = 1)

#for interval-valued data
c1 <- runif(10, 10, 20) %>% round(digits = 0)
c2 <- runif(10, -50, -10) %>% round(digits = 0)

#build simulated data
d <- data.frame(a1 = a1, a2 = a2, a3 = 1-(a1+a2),
                c1 = c1, c2 = c2,
                b1 = b1, b2 = b2, b3 = 1-(b1+b2))

#transformation
classic2sym(d, groupby = "customize",
            minData = d$c2,
            maxData = d$c1,
            modalData = list(1:3, 6:8))#two modal data

#extract the data
symObj<-classic2sym(iris)
symObj$intervalData       #interval data
symObj$rawData            #raw data
symObj$clusterResult      #cluster result
symObj$statisticsDF       #statistics

Generic function for the correlation

Description

This function compute the symbolic correlation

Usage

cor(x, ...)

## Default S3 method:
cor(
  x,
  y = NULL,
  use = "everything",
  method = c("pearson", "kendall", "spearman"),
  ...
)

## S3 method for class 'symbolic_tbl'
cor(x, ...)

## S3 method for class 'symbolic_interval'
cor(x, y, method = c("centers", "B", "BD", "BG"), ...)

Arguments

x

First symbolic variables.

...

As in R cor function.

y

Second symbolic variables.

use

an optional character string giving a method for computing correlation in the presence of missing values. This must be (an abbreviation of) one of the strings 'everything', 'all.obs', 'complete.obs', 'na.or.complete', or 'pairwise.complete.obs'.

method

The method to use.

Details

Supported interval-valued methods are:

For "B", "BD", and "BG", the denominator uses the corresponding method-matched standard deviation.

"BG" is retained as a software method label. Its covariance follows Irpino and Verde (2015), Equation (24), where it is attributed to Bertrand and Goupil. The original Bertrand–Goupil chapter gives univariate means and variances but does not define a covariance or correlation. The package normalizes this covariance by its self-covariances:

R_{BG}(X,Y) = \frac{C_{BG}(X,Y)}{\sqrt{C_{BG}(X,X) C_{BG}(Y,Y)}}.

Here C_{BG} is the covariance of the interval centers with divisor n; see cov. When both center variances are positive, this equals the Pearson correlation of the interval centers. This normalization differs from Equation (30) of Irpino and Verde (2015), which uses the product S_X S_Y of the mixture standard deviations. The "BG" option does not implement their Wasserstein-based correlation.

Value

Return a real number in [-1, 1].

References

Bertrand, Patrice and Goupil, Francoise (2000). Descriptive Statistics for Symbolic Data. In Hans-Hermann Bock and Edwin Diday (eds.), Analysis of Symbolic Data, pp. 106–124. Berlin and Heidelberg: Springer.

Billard, Lynne and Diday, Edwin (2006). Symbolic Data Analysis: Conceptual Statistics and Data Mining. Chichester, UK: John Wiley and Sons.

Billard, Lynne (2008). Sample covariance functions for complex quantitative data. In Proceedings of the World IASC Conference, pp. 157–163, Yokohama, Japan.

Irpino, Antonio and Verde, Rosanna (2015). Basic Statistics for Distributional Symbolic Variables: A New Metric-based Approach. Advances in Data Analysis and Classification, 9, 143–175.

Rodriguez-Rojas, Oldemar (2000). Classification et modeles lineaires en analyse des donnees symboliques. PhD thesis, Universite Paris IX Dauphine.

See Also

cov


Generic function for the covariance

Description

This function compute the symbolic covariance.

Usage

cov(x, ...)

## Default S3 method:
cov(
  x,
  y = NULL,
  use = "everything",
  method = c("pearson", "kendall", "spearman"),
  ...
)

## S3 method for class 'symbolic_tbl'
cov(x, ...)

## S3 method for class 'symbolic_interval'
cov(x, y = NULL, method = c("centers", "B", "BD", "BG"), na.rm = FALSE, ...)

Arguments

x

First symbolic variables.

...

As in R cov function.

y

Second symbolic variables.

use

an optional character string giving a method for computing covariances in the presence of missing values. This must be (an abbreviation of) one of the strings 'everything', 'all.obs', 'complete.obs', 'na.or.complete', or 'pairwise.complete.obs'.

method

The method to use.

na.rm

As in R cov function.

Details

Supported interval-valued methods are:

"BG" is retained as a software method label. The implemented covariance follows Irpino and Verde (2015), Equation (24), where it is attributed to Bertrand and Goupil. The original Bertrand–Goupil chapter gives univariate means and variances but does not define a covariance or correlation. For n paired intervals with centers c_{Xi} and c_{Yi}, the implemented covariance is

C_{BG}(X,Y) = \frac{1}{n}\sum_{i=1}^{n}(c_{Xi}-\bar{c}_X)(c_{Yi}-\bar{c}_Y).

Thus, method = "BG" uses divisor n, whereas method = "centers" uses the ordinary sample covariance of the centers with divisor n-1. The "BG" option does not implement the Wasserstein-based covariance proposed by Irpino and Verde (2015).

Value

Return a real number.

References

Bertrand, Patrice and Goupil, Francoise (2000). Descriptive Statistics for Symbolic Data. In Hans-Hermann Bock and Edwin Diday (eds.), Analysis of Symbolic Data, pp. 106–124. Berlin and Heidelberg: Springer.

Billard, Lynne and Diday, Edwin (2006). Symbolic Data Analysis: Conceptual Statistics and Data Mining. Chichester, UK: John Wiley and Sons.

Billard, Lynne (2008). Sample covariance functions for complex quantitative data. In Proceedings of the World IASC Conference, pp. 157–163, Yokohama, Japan.

Irpino, Antonio and Verde, Rosanna (2015). Basic Statistics for Distributional Symbolic Variables: A New Metric-based Approach. Advances in Data Analysis and Classification, 9, 143–175.

Rodriguez-Rojas, Oldemar (2000). Classification et modeles lineaires en analyse des donnees symboliques. PhD thesis, Universite Paris IX Dauphine.

See Also

cor


Face Data Example

Description

Symbolic data matrix with all the variables of interval type. The 27 rows are nine subjects (FRA, HUS, INC, ISA, JPL, KHA, LOT, PHI, ROM) with three image sequences per subject; AD, BC, AH, DH, EH and GH are six positive-width interval variables.

Usage

data('facedata')

Format

$I;AD;AD;$I;BC;BC;.........

HUS1;$I;168.86;172.84;$I;58.55;63.39;.........
HUS2;$I;169.85;175.03;$I;60.21;64.38;.........
HUS3;$I;168.76;175.15;$I;61.4;63.51;.........
INC1;$I;155.26;160.45;$I;53.15;60.21;.........
INC2;$I;156.26;161.31;$I;51.09;60.07;.........
INC3;$I;154.47;160.31;$I;55.08;59.03;.........
ISA1;$I;164;168;$I;55.01;60.03;.........
ISA2;$I;163;170;$I;54.04;59;.........
ISA3;$I;164.01;169.01;$I;55;59.01;.........
JPL1;$I;167.11;171.19;$I;61.03;65.01;.........
JPL2;$I;169.14;173.18;$I;60.07;65.07;.........
JPL3;$I;169.03;170.11;$I;59.01;65.01;.........
KHA1;$I;149.34;155.54;$I;54.15;59.14;.........
KHA2;$I;149.34;155.32;$I;52.04;58.22;.........
KHA3;$I;150.33;157.26;$I;52.09;60.21;.........
LOT1;$I;152.64;157.62;$I;51.35;56.22;.........
LOT2;$I;154.64;157.62;$I;52.24;56.32;.........
LOT3;$I;154.83;157.81;$I;50.36;55.23;.........
PHI1;$I;163.08;167.07;$I;66.03;68.07;.........
PHI2;$I;164;168.03;$I;65.03;68.12;.........
PHI3;$I;161.01;167;$I;64.07;69.01;.........
ROM1;$I;167.15;171.24;$I;64.07;68.07;.........
ROM2;$I;168.15;172.14;$I;63.13;68.07;.........
ROM3;$I;167.11;171.19;$I;63.13;68.03;.........

Source

Adapted from RSDA::facedata; see https://CRAN.R-project.org/package=RSDA.

References

Arce Garro, Jorge and Rodríguez Rojas, Oldemar (2019). Optimized dimensionality reduction methods for interval-valued variables and their application to facial recognition. Entropy, 21(10), 1016, pp. 9–10. doi:10.3390/e21101016

Billard, Lynne and Diday, Edwin (2006). Symbolic Data Analysis: Conceptual Statistics and Data Mining. Chichester, UK: John Wiley and Sons.

Examples


data(facedata)
ggInterval_hist(facedata, aes(x = AD))


A symbolic object by R6 class for interval analysis and ggplot

Description

This is an object that will be used to make a ggplot object.A ggInterval object contains both classic data that user have and interval data which we transform.More over,some basic statistics from row data will also be recorded in this object,and the interval data which is from RSDA transformation will still contain RSDA properties.

Public fields

rawData

the data from user.

statisticsDF

contains min max mean median dataframe for each group of symbolic data

intervalData

interval data from RSDA type

clusterResult

clustering result

Methods

Public methods


Method new()

initialize all data, check whether satisfy theirs form

Usage
ggInterval$new(
  rawData = NULL,
  statisticsDF = NULL,
  intervalData = NULL,
  clusterResult = NULL
)

Method clone()

The objects of this class are cloneable with this method.

Usage
ggInterval$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


Visualize a 2-dimension histogram for interval-valued data

Description

Visualize the joint distribution of two continuous interval-valued variables by dividing the x axis and y axis into rectangles and calculating the frequency of each observation interval in every rectangle.

Usage

ggInterval_2Dhist(data = NULL, mapping = aes(NULL),
method = "equal-bin", xBins = 14, yBins = 16,
display = "p", palette = "Blues", direction = 1, tau = 0,
removeZero = FALSE, cell_labels = FALSE, label_rule = "above-mean",
addFreq = NULL)

Arguments

data

A ggInterval object. It can also be either an RSDA object or a classical data frame, which will be automatically converted to ggInterval data.

mapping

Set of aesthetic mappings created by aes() or aes_(). If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping. It is the same as the mapping of ggplot2.

method

Histogram partition method. Use "equal-bin" for equally spaced bins or "unequal-bin" for non-equidistant bins defined by the observed interval endpoints.

xBins

Number of x-axis bins used when method = "equal-bin".

yBins

Number of y-axis bins used when method = "equal-bin".

display

Metric shown in the cells. Use "p" for relative frequency, "f" for weighted frequency, or "h" for density.

palette

ColorBrewer palette passed to scale_fill_distiller().

direction

Direction passed to scale_fill_distiller().

tau

Non-negative tolerance used when method = "unequal-bin". Consecutive breakpoints whose gaps are smaller than tau are merged.

removeZero

Whether remove data whose frequency is equal to zero.

cell_labels

Logical. If TRUE, add frequency labels to cells.

label_rule

Rule used when cell_labels = TRUE. The default "above-mean" shows only cells whose displayed values exceed the mean cell value. Alternatives are "nonzero" and "all".

addFreq

Deprecated alias for cell_labels.

Details

Cell weighted frequency f is the sum of products of axis overlap fractions and sums to n observations per panel. Relative frequency is p = f/n; density is h = p/area, so sum(h * area) = 1. Bins are left-closed and right-open, with the final right endpoint included. A point interval contributes unit mass to exactly one bin on each axis. Equal-bin breaks are A + g (B - A) / r, g = 0, ..., r, using exact global endpoints A and B. A constant axis is padded by max(abs(A) * 0.05, 0.5) on each side (0.5 at zero). Endpoints must be finite, non-missing and ordered. Unequal-bin breaks use sorted unique endpoints; tau merges chains of gaps smaller than tau, retaining outer endpoints and averaging interior groups. Constant unequal-bin axes use the same padding. Rounded bracket labels do not indicate endpoint ownership; allocations use unrounded breaks. In equal-bin mode xBins and yBins must each be finite numeric positive integer scalars, and their sum must not exceed 200. Unequal-bin mode ignores them.

Value

A list with $plot and a Table (x, y) data frame. The plot data contain unrounded cell metrics; table cells are rounded to three decimals and endpoint labels to two decimals. Frequency and probability table margins sum the rounded cells.

Examples

ggInterval_2Dhist(oils, aes(x = GRA, y = FRE),
  xBins = 5, yBins = 5,
  display = "p",
  palette = "Blues",
  cell_labels = TRUE)

ggInterval_2Dhist(oils, aes(x = GRA, y = FRE),
  method = "unequal-bin",
  display = "p",
  palette = "Blues",
  tau = 0.5)


2-Dimension histogram matrix

Description

Visualize all continuous interval-valued variables with a matrix of 2D histograms. Each off-diagonal panel shows a 2D histogram for a pair of variables, and each diagonal panel displays the variable name.

Usage

ggInterval_2DhistMatrix(data = NULL, mapping = aes(NULL),
method = "equal-bin", xBins = 8, yBins = 8,
display = "p", palette = "Blues", direction = 1, tau = 0,
removeZero = FALSE, cell_labels = FALSE, label_rule = "above-mean",
addFreq = NULL)

Arguments

data

A ggInterval object. It can also be either an RSDA object or a classical data frame, which will be automatically converted to ggInterval data.

mapping

Set of aesthetic mappings created by aes() or aes_(). If specified and inherit.aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. It is the same as the mapping of ggplot2. This function ignores x and y mappings and plots all continuous interval-valued variables.

method

Histogram partition method. Use "equal-bin" for equally spaced bins or "unequal-bin" for non-equidistant bins defined by the observed interval endpoints.

xBins

Number of x-axis bins used when method = "equal-bin".

yBins

Number of y-axis bins used when method = "equal-bin".

display

Metric shown in the cells. Use "p" for relative frequency, "f" for weighted frequency, or "h" for density.

palette

ColorBrewer palette passed to scale_fill_distiller().

direction

Direction passed to scale_fill_distiller().

tau

Non-negative tolerance used when method = "unequal-bin". Consecutive breakpoints whose gaps are smaller than tau are merged.

removeZero

Whether remove cells whose frequency is equal to zero.

cell_labels

Logical. If TRUE, add cell labels.

label_rule

Rule used when cell_labels = TRUE. The default "above-mean" shows only cells whose displayed values exceed the mean value within the matrix. Alternatives are "nonzero" and "all".

addFreq

Deprecated alias for cell_labels.

Details

Cell weighted frequency f is the sum of products of axis overlap fractions and sums to n observations per panel. Relative frequency is p = f/n; density is h = p/area, so sum(h * area) = 1. Bins are left-closed and right-open, with the final right endpoint included. A point interval contributes unit mass to exactly one bin on each axis. Equal-bin breaks are A + g (B - A) / r, g = 0, ..., r, using exact global endpoints A and B. A constant axis is padded by max(abs(A) * 0.05, 0.5) on each side (0.5 at zero). Endpoints must be finite, non-missing and ordered. Unequal-bin breaks use sorted unique endpoints; tau merges chains of gaps smaller than tau, retaining outer endpoints and averaging interior groups. Constant unequal-bin axes use the same padding. Rounded bracket labels do not indicate endpoint ownership; allocations use unrounded breaks. In equal-bin mode xBins and yBins must each be finite numeric positive integer scalars, and their sum must not exceed 100. Unequal-bin mode ignores them.

Value

A ggplot whose $data holds panel cell data, including f, p, h, area, xv, yv, and isPlot. Rows with isPlot = TRUE are off-diagonal cells.

Examples

ggInterval_2DhistMatrix(
  oils,
  xBins = 5,
  yBins = 5,
  display = "p",
  palette = "Blues",
  cell_labels = TRUE
)

ggInterval_2DhistMatrix(
  oils,
  method = "unequal-bin",
  display = "p",
  palette = "Blues",
  tau = 0.5
)


3D scatter plot for interval data

Description

Visualize the three continuous variable distribution by collecting all vertices in each interval to form a shape of cube.Also show the difference between each group.

Usage

ggInterval_3Dscatterplot(data = NULL,mapping = aes(NULL),scale=FALSE)

Arguments

data

A ggInterval object. It can also be either an RSDA object or a classical data frame, which will be automatically converted to ggInterval data.

mapping

Set of aesthetic mappings created by aes() or aes_(). If specified and inherit. aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping. It is the same as the mapping of ggplot2.

scale

A boolean variable. TRUE standardizes the data and FALSE leaves the data unchanged. If variance is too large(or small) or the difference between two variables are too large,it will be distorted or difficult to see, which may happen when variables are measured in different units.

Value

Return a ggplot2 object (It will still be 2-Dimension).

Examples

ggInterval_3Dscatterplot(facedata[1:5, ], aes(x = BC, y = EH, z = GH))


Pearson correlations of interval centers and full ranges

Description

Compare associations among interval centers and full ranges, optionally separating pooled correlations from correlations after removing group means.

Usage

ggInterval_CRcor(data, variables = NULL, group = NULL, labels = TRUE)

Arguments

data

An interval input accepted by ggInterval: a symbolic table, an object with an 'intervalData' component, or a list containing numeric 'lower' and 'upper' matrices.

variables

Optional character vector selecting interval variables.

group

Optional vector of group labels, with one nonmissing value per observation. Group means are removed separately from every derived column.

labels

Logical scalar. Print correlations to two decimal places on the tiles. Diagnostic values retain their full numerical precision.

Details

For variable j, C_j=(a_j+b_j)/2 is its center and R_j=b_j-a_j is its full range. Derived columns are ordered 'C1', ..., 'Cp', 'R1', ..., 'Rp'. Rows run from top to bottom in this same order, so the lower-left triangle displays pooled Pearson correlations. When 'group' is supplied, the upper-right triangle displays Pearson correlations of residuals obtained by subtracting each group's column means. Otherwise both triangles display pooled correlations. Diagonal entries contain pooled self-correlations: one for a varying column, 'NA' otherwise.

Group-demeaned correlations are descriptive associations among the residuals pooled over observations, not averages of group-specific correlations. They are not intraclass correlations (ICCs), tests of group effects, or an implementation of the B, BD, or BG interval-correlation estimators. Constant columns have undefined correlations, shown as grey 'NA' tiles. Singleton groups contribute zero residuals and trigger a warning. If all derived columns have zero residual variance, an informative error is raised.

Value

An ordinary 'ggplot' object with an 'interval_diagnostics' attribute. It contains the derived 'values', 'pooled' and 'group_demeaned' correlation matrices, 'residuals', the mixed 'displayed' matrix, a 'cells' table, a 'variables' key, and 'settings'. Undefined correlations remain 'NA'.

Examples

library(ggInterval)
x <- list(lower = cbind(X = c(0, 2, 5)),
          upper = cbind(X = c(2, 5, 9)))
ggInterval_CRcor(x)

Center-range plot for interval data

Description

Visualize the relation between interval centers and ranges, with mean reference lines and an optional ellipse overlay.

Usage

ggInterval_CRplot(data = NULL,mapping = aes(NULL),plotAll=FALSE,
                         addEllipse = TRUE,
                         ellipseFill = "blue",
                         ellipseAlpha = 0.3)

Arguments

data

A ggInterval object. It can also be either RSDA object or classical data frame,which will be automatically convert to ggInterval data.

mapping

Set of aesthetic mappings created by aes() or aes_(). If specified and inherit. aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping. It is the same as the mapping of ggplot2.

plotAll

booleans, if TRUE, plot all variable together

addEllipse

logical, if TRUE (default), add a shaded ellipse layer.

ellipseFill

fill color of the ellipse layer. Default is "blue".

ellipseAlpha

alpha level of the ellipse layer. Default is 0.3.

Value

Return a ggplot2 object.

Examples

mydata <- ggInterval::facedata
ggInterval_CRplot(mydata, aes(x = AD, col = "blue", shape = 2))
ggInterval_CRplot(mydata, plotAll = TRUE)
ggInterval_CRplot(mydata, plotAll = TRUE, addEllipse = FALSE)

A min-max plot for interval data

Description

Visualize the range of the variables of each observations by marking minimal and maximal point.

Usage

ggInterval_MMplot(data = NULL,mapping = aes(NULL),
          scaleXY = "local",plotAll=FALSE)

Arguments

data

A ggInterval object. It can also be either RSDA object or classical data frame,which will be automatically convert to ggInterval data.

mapping

Set of aesthetic mappings created by aes() or aes_(). If specified and inherit. aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping.

scaleXY

default "local", which means limits of x-axis and y-axis depend on their own variable. "global" means limits of them depend on all variables that user input.

plotAll

booleans, if TRUE, plot all variable together

Value

Return a ggplot2 object.

Examples

mydata <- ggInterval::facedata
ggInterval_MMplot(mydata, aes(x = AD))
ggInterval_MMplot(mydata, aes(x = AD, size = 3))
ggInterval_MMplot(mydata, plotAll = TRUE, scaleXY = "global") +
  theme_classic()

Vertices PCA for interval data

Description

ggInterval_PCA performs a principal components analysis on the given numeric interval data and returns the results of princomp, a ggplot object, and interval scores.

Usage

ggInterval_PCA(data = NULL,mapping = aes(NULL),plot=TRUE,
                      concepts_group=NULL, poly = FALSE, adjust = TRUE,
                      showLabels = TRUE, labelSize = 3,
                      checkOverlap = FALSE)

Arguments

data

A ggInterval object. It can also be either RSDA object or classical data frame, which will be automatically convert to ggInterval data.

mapping

Set of aesthetic mappings created by aes() or aes_(). If specified and inherit. aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping. It is the same as the mapping of ggplot2.

plot

Boolean variable,Auto plot (if TRUE).It can also plot by its inner object

concepts_group

color with each group of concept

poly

Logical. If TRUE, draw the projected edges of each hyperrectangle (polytope display) instead of the bounding rectangles. This display needs all 2^p distinct vertices of every observation; data with zero-width intervals or vertices shared between observations give an error.

adjust

adjust sign of the principal component

showLabels

Logical. If TRUE, label interval scores in the plot.

labelSize

Numeric text size used when showLabels = TRUE.

checkOverlap

Logical. Passed to geom_text() to suppress overlapping labels when needed.

Value

The princomp result (class "princomp"), augmented with $scores_interval, a symbolic table of interval scores, and $ggplotPCA, the ggplot of PC1 and PC2. Vertex coordinates are standardized column-wise with scale before princomp.

Examples


Subjects <- substr(rownames(facedata), 1, 3)
p <- ggInterval_PCA(facedata, plot = FALSE, concepts_group = Subjects)
p$ggplotPCA
p$scores_interval
ggInterval_PCA(facedata, poly = TRUE, concepts_group = Subjects)



A interval Box plot

Description

Visualize the one continuous variable distribution using one of three interval-aware boxplot styles.

Usage

ggInterval_boxplot(data = NULL,mapping = aes(NULL),plotAll=FALSE,
width_type = "violin-like")

Arguments

data

A ggInterval object. It can also be either RSDA object or classical data frame, which will be automatically convert to ggInterval data.

mapping

Set of aesthetic mappings created by aes() or aes_(). If specified and inherit. aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping. It is the same as the mapping of ggplot2.

plotAll

booleans, if TRUE, plot all variable together

width_type

Box-width style. Use "violin-like" (default) to let the rectangle widths reflect local interval concentration, "quantile-depth" for progressively narrower quantile boxes, or "side-by-side" for conventional boxplots of the lower and upper bounds shown next to each other.

Value

Return a ggplot2 object.

Examples

mydata <- ggInterval::facedata
ggInterval_boxplot(mydata, aes(x = AD))
ggInterval_boxplot(mydata, aes(x = AD), width_type = "quantile-depth")
ggInterval_boxplot(mydata, plotAll = TRUE, width_type = "side-by-side")


Correlation heatmap for interval-valued data

Description

Visualize pairwise symbolic correlations between interval-valued variables with a heatmap. This plot is especially useful for summarizing multivariate dependence structures before more formal modeling or dimension reduction.

Usage

ggInterval_corrplot(
  data = NULL,
  method = c("centers", "B", "BD", "BG"),
  triangle = c("lower", "upper", "full"),
  showValues = TRUE,
  digits = 2,
  showLegend = TRUE
)

Arguments

data

A ggInterval object. It can also be either an RSDA object or a classical data frame, which will be automatically converted to ggInterval data.

method

Correlation method for interval-valued variables. It must be one of "centers" (interval centers), "B" (Billard), "BD" (Billard-Diday), or "BG" (Bertrand-Goupil).

triangle

Which part of the symmetric correlation matrix to display. It can be "lower", "upper", or "full".

showValues

Logical. If TRUE, print the correlation values in each cell.

digits

Number of digits used when showValues = TRUE.

showLegend

Logical. If TRUE, display the fill legend.

Value

Return a ggplot2 object.

References

Bertrand, Patrice and Goupil, Francoise (2000). Descriptive Statistics for Symbolic Data. In Hans-Hermann Bock and Edwin Diday (eds.), Analysis of Symbolic Data, pp. 106–124. Berlin and Heidelberg: Springer.

Billard, Lynne and Diday, Edwin (2006). Symbolic Data Analysis: Conceptual Statistics and Data Mining. Chichester, UK: John Wiley and Sons.

Billard, Lynne (2008). Sample covariance functions for complex quantitative data. In Proceedings of the World IASC Conference, pp. 157–163, Yokohama, Japan.

Examples

ggInterval_corrplot(facedata)

ggInterval_corrplot(facedata, method = "BG", triangle = "full")

Decompose endpoint deviation into center and range contributions

Description

Each bar decomposes an observation's squared endpoint deviation from a reference into center and full-range contributions. By default the reference consists of the componentwise sample medians of the centers and full ranges, separately within each supplied group. Without groups, pooled medians are used. This is a descriptive geometric decomposition, not a Shapley attribution or a calibrated outlier test.

Usage

ggInterval_deviation(
  data,
  variables = NULL,
  group = NULL,
  scale = NULL,
  reference = NULL,
  labels = NULL,
  highlight = NULL
)

Arguments

data

Interval input accepted by ggInterval: a list with numeric matrices named 'lower' and 'upper', or a supported symbolic interval table.

variables

Selected interval-variable names; 'NULL' selects all interval variables.

group

Optional grouping vector of length equal to the number of rows.

scale

Positive finite numeric vector, one scale per selected variable. The default is each variable's global endpoint span. Variables whose default span is zero are omitted and reported in the diagnostics. If a supplied reference differs on a constant variable, explicit positive scales are required so its deviation is not silently omitted.

reference

Optional list with finite numeric vectors 'center' and 'range', each of length equal to the number of selected variables. This supplies one common reference for every observation, overriding the group-median references. Reference full ranges must be nonnegative.

labels

Optional distinct, nonmissing character observation IDs.

highlight

Optional logical vector identifying observations to outline. It must contain externally supplied labels, such as known injected rows; the function does not detect outliers.

Details

For center difference 'dc', full-range difference 'dr' and positive scale 's', the contributions are 'sum((dc/s)^2)' and 'sum((dr/(2*s))^2)'. Their sum equals the sum, over variables, of the mean squared standardized deviations of the two endpoints from reference endpoints 'center - range/2' and 'center + range/2'. Bars are ordered by decreasing total deviation, with input order breaking ties. All observations remain in the plot. A supplied reference need not be an observed interval.

Value

An ordinary 'ggplot' object. Its 'interval_diagnostics' attribute contains the contributions in input order, reference matrices, scales, omitted variables, plotting order, and the endpoint identity check.

Examples

library(ggInterval)
endpoints <- list(
  lower = cbind(X1 = c(0, 1, 4), X2 = c(1, 0, 3)),
  upper = cbind(X1 = c(2, 5, 6), X2 = c(3, 2, 7)))
ggInterval_deviation(endpoints)
ggInterval_deviation(endpoints, scale = c(2, 2),
  reference = list(center = c(2, 2), range = c(2, 2)))

Empirical CDF envelopes for interval observations

Description

Display the lower and upper empirical CDF envelopes determined by interval endpoints, optionally with the empirical CDF of the interval midpoints.

Usage

ggInterval_ecdf(data, variables = NULL, midpoint = TRUE)

Arguments

data

An interval input accepted by ggInterval: a symbolic table, an object with an 'intervalData' component, or a list containing numeric 'lower' and 'upper' matrices.

variables

Optional character vector selecting variables, in display order. The default uses all interval variables.

midpoint

Logical scalar. Include a dashed midpoint ECDF when 'TRUE'.

Details

For intervals [a_i,b_i], the lower envelope is F_b(t)=n^{-1}\sum_i 1\{b_i\leq t\} and the upper envelope is F_a(t)=n^{-1}\sum_i 1\{a_i\leq t\}. Thus F_b(t)\leq F_a(t). Every empirical CDF formed by choosing one value from each interval lies between these envelopes. All observations receive equal weight. These are endpoint bounds, not a confidence band or a model for values inside an interval. The optional midpoint curve is a point-summary ECDF.

Bounds are evaluated at the sorted, unique endpoint knots. Shading uses constant-height rectangles between knots and boundary curves are right-continuous steps; no linear interpolation is used. Variables are faceted with separate horizontal scales and a common probability scale.

Value

An ordinary 'ggplot' object. Its 'interval_diagnostics' attribute is a list containing 'knots' (exact endpoint CDF values), 'band' (the constant segments used for shading, including plot margins), 'midpoint' (exact midpoint knots and CDF values, or 'NULL'), and 'settings'. No rounded values are used in these calculations.

Examples

library(ggInterval)
x <- list(lower = cbind(X = c(0, 2)), upper = cbind(X = c(2, 4)))
ggInterval_ecdf(x)

Histogram for symbolic data with equal-bin or unequal-bin.

Description

Visualize the continuous variable distribution by dividing the x axis into bins,and calculating the frequency of observation interval in each bin.

Usage

ggInterval_hist(data = NULL,mapping = aes(NULL),method="equal-bin",bins=10,
 plotAll = FALSE, position = "identity", alpha = 0.5)

Arguments

data

A ggInterval object.It can also be either RSDA object or classical data frame,which will be automatically convert to ggInterval data.

mapping

Set of aesthetic mappings created by aes() or aes_(). If specified and inherit. aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping. It is the same as the mapping of ggplot2.

method

It can be "equal-bin" (default) or "unequal-bin". Equal-bin means the histogram uses equally spaced intervals. Unequal-bin means the bin widths are determined by the data, so the argument bins is unused in that case.

bins

Finite numeric positive integer scalar for equal-bin mode. Values above 200 warn; values above 1000 error. Ignored in unequal-bin mode.

plotAll

boolean, whether plot all variables, default FALSE.

position

"stack" or "identity"

alpha

fill alpha

Details

For equal-bin mode, let A be the minimum lower endpoint and B the maximum upper endpoint, pooled across all groups. With r bins, breaks are A + g (B - A) / r for g = 0, ..., r, generated with exactly r + 1 values. A positive-width interval contributes its overlap length divided by its width: [1,5] with breaks 0,2,4,6 contributes 1/4, 1/2, 1/4. A point contributes one to its left-closed, right-open bin; the final right endpoint belongs to the final bin. Constant ranges are padded on both sides by max(abs(A) * 0.05, 0.5), including padding 0.5 at zero. Allocation uses unrounded breaks; displayed endpoints are rounded to two decimals and retain bracket labels, which do not indicate endpoint ownership. Endpoints must be finite, non-missing and ordered (lower <= upper). In unequal-bin mode, the unchanged 0.01 grid counts intervals covering each grid location. A constant variable (all intervals equal to one value v) is represented by its coverage count n at the exact value v as a zero-width rectangle (vertical spike), without constructing a grid. The equal-bin padding rule does not apply there. "Cumulative Concepts" are coverage counts, not probabilities, and need not integrate to one. This method ignores bins and does not support grouping.

Value

An object of class ggInterval_hist_result. A direct call displays the histogram, and the returned object stores the ggplot object in $plot together with the accompanying frequency tables. Tables are named Table <var> or Table <var>: <group>. Equal-bin tables contain Interval, Observed.Frequency and Relative.Frequency; unequal-bin tables contain Interval and Cumulative.Concepts (the display name is "Cumulative Concepts").

Examples

mydata <- ggInterval::facedata
ggInterval_hist(mydata, aes(x = AD), bins = 10)

hist_obj <- ggInterval_hist(mydata, plotAll = TRUE, bins = 10)
hist_obj
hist_obj$`Table AD`

ggInterval_hist(mydata, aes(x = AD), method = "unequal-bin")


Index image plot for interval-valued data

Description

Visualize interval-valued observations with color strips. For a single variable, the display acts as a color-based analogue of an index plot. When plotAll = TRUE, the function produces a multivariate image plot across all continuous interval-valued variables.

Usage

ggInterval_indexImage(data = NULL, mapping = aes(NULL),
column_condition = TRUE, full_strip = FALSE, plotAll = FALSE)

Arguments

data

A ggInterval object. It can also be either RSDA object or classical data frame,which will be automatically convert to ggInterval data.

mapping

Set of aesthetic mappings created by aes() or aes_(). If specified and inherit. aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping.

column_condition

Logical. If TRUE, the color scale is applied separately within each variable (column condition). If FALSE, one common color scale is applied to the whole matrix (matrix condition).

full_strip

Logical. If TRUE, each strip spans the full plotting width. If FALSE, strip widths reflect the interval ranges.

plotAll

Logical. If TRUE, produce a multivariate image plot for all continuous interval-valued variables. The default is FALSE.

Value

Return a ggplot2 object.

Examples

mydata <- ggInterval::facedata
p <- ggInterval_indexImage(mydata, aes(x = AD),
  full_strip = TRUE, column_condition = TRUE)
# Recommend adding coord_flip() to make the single-variable display clearer.
p + coord_flip()
ggInterval_indexImage(
  mydata,
  plotAll = TRUE,
  full_strip = TRUE,
  column_condition = FALSE
) +
  scale_colour_distiller(palette = "Blues", direction = 1)
ggInterval_indexImage(mydata, plotAll = TRUE, full_strip = FALSE)


Plot the range of each observations

Description

Visualize the range of the variables of each observations by using a kind of margin bar that indicate the minimal and maximal of observations.

Usage

ggInterval_indexplot(data = NULL,mapping = aes(NULL),
plotAll = FALSE, row_order = "o", user_order = NULL, labels = FALSE)

Arguments

data

A ggInterval object. It can also be either RSDA object or classical data frame,which will be automatically convert to ggInterval data.

mapping

Set of aesthetic mappings created by aes() or aes_(). If specified and inherit. aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping. It is the same as the mapping of ggplot2.

plotAll

plot all variables

row_order

Row ordering used when plotAll = TRUE: "o" for the original order, "c" for ascending interval centers within each variable panel, "r" for ascending interval ranges within each variable panel, and "u" for a user-defined permutation supplied through user_order.

user_order

User-defined row permutation used when row_order = "u" and plotAll = TRUE. Supply either an integer permutation of 1:nrow(data) or a character permutation of the row names.

labels

Logical. When TRUE and plotAll = TRUE, repeat the row labels inside each variable panel. This is especially useful for ordered displays with row_order = "c" or "r". For ordered displays, the outer left-side row labels are suppressed by default.

Value

Return a ggplot2 object.

Examples

mydata <- ggInterval::facedata
Subjects <- substr(rownames(mydata), 1, 3)
ggInterval_indexplot(mydata, aes(x = AD))
ggInterval_indexplot(mydata, aes(x = AD, fill = Subjects))
ggInterval_indexplot(mydata, plotAll = TRUE, row_order = "c")
custom_order <- c(19:21, 22:24, 1:18, 25:27)
ggInterval_indexplot(mydata["AD"], plotAll = TRUE,
                     row_order = "u", user_order = custom_order)
ggInterval_indexplot(mydata, plotAll = TRUE, row_order = "c", labels = TRUE)


Interval-valued line plot

Description

Visualize interval-valued data along an ordered horizontal axis. A line can connect the centers of intervals at each position, with crossbars or errorbars indicating the interval range. When the horizontal axis is time, the display becomes an interval-valued time-series plot.

Usage

ggInterval_lineplot(data = NULL, mapping = aes(NULL),
barWidth = 0.5, add_line = TRUE)

ggInterval_tsplot(data = NULL, mapping = aes(NULL),
barWidth = 0.5, add_line = TRUE)

Arguments

data

A ggInterval object. It can also be either RSDA object or classical data frame, which will be automatically convert to ggInterval data.

mapping

Set of aesthetic mappings created by aes() or aes_(). Must include x for the ordered variable and y for the interval variable. Optional aesthetics include group and fill for multiple line series. It is the same as the mapping of ggplot2.

barWidth

The width of the crossbar or errorbar indicating the interval range at each x position. Default is 0.5.

add_line

Logical; if TRUE (default), connect interval centers with a line. Set FALSE when adding a customized line layer with geom_line(...).

Details

The financial example uses TTR::ttrc, a randomly generated series that does not represent an actual security. The built-in dataset stock.data.LH stores its January–March 1985 low-high intervals and auxiliary columns as a directly inspectable symbolic table.

Value

Return a ggplot2 object.

Examples


if (requireNamespace("TTR", quietly = TRUE)) {
  data("ttrc", package = "TTR")
  stock.data <- subset(
    ttrc[, c("Date", "Close", "Low", "High")],
    format(Date, "%Y-%m") %in% c("1985-01", "1985-02", "1985-03")
  )
  stock.data$Month <- factor(
    month.abb[as.integer(format(stock.data$Date, "%m"))],
    levels = month.abb[1:3]
  )
  stock.data$Day <- as.integer(format(stock.data$Date, "%d"))
  stock.i <- classic2sym(
    stock.data,
    groupby = "customize",
    minData = stock.data$Low,
    maxData = stock.data$High
  )
  ggInterval_lineplot(stock.i, aes(y = V1, x = Day), barWidth = 0.6) +
    geom_point(aes(y = Close), shape = 21, fill = "#D95F02",
               color = "black", size = 1.6, stroke = 0.2) +
    coord_cartesian(xlim = c(1, 31), expand = FALSE) +
    facet_wrap(~Month, ncol = 1, scales = "free_y") +
    scale_x_continuous(breaks = c(1, 8, 15, 22, 29)) +
    labs(x = "Day of month", y = "Price") +
    ggthemes::theme_economist() +
    theme(strip.text = element_text(face = "bold"))
}


Display pairwise geometric overlap of interval boxes

Description

This display compares observations, not variables. Each observation is the Cartesian product of its selected intervals. Colours show intersection volume divided by union volume (box Jaccard overlap), not symbolic correlation or agreement between unobserved within-box distributions.

Usage

ggInterval_overlap(
  data,
  variables = NULL,
  group = NULL,
  labels = NULL,
  zero_width = c("error", "na")
)

Arguments

data

Interval input accepted by ggInterval: a list with numeric matrices named 'lower' and 'upper', or a supported symbolic interval table.

variables

Selected interval-variable names; 'NULL' selects all interval variables.

group

Optional grouping vector. Factor levels determine group order; otherwise groups follow first appearance. Input order is retained within groups. Thin lines separate groups.

labels

Optional distinct, nonmissing character observation IDs.

zero_width

How to handle boxes with zero width on any selected axis. The default '"error"' explains that such boxes have zero volume. With '"na"', every pair involving such a box is explicitly missing, including its diagonal, rather than being assigned an artificial zero or one.

Details

Volumes are evaluated through logarithms and relative scaling to avoid underflow from products across many axes. Disjoint positive-volume boxes have overlap zero, identical boxes have overlap one, and touching boundaries have zero intersection volume. Positive affine rescaling of any axis leaves the result unchanged. Axis labels are thinned for larger tables; diagnostics retain every observation ID and every pairwise value.

Value

An ordinary 'ggplot' object. Its 'interval_diagnostics' attribute contains the full overlap matrix in input order, observation IDs, group ordering, and the indices of degenerate boxes.

Examples

library(ggInterval)
endpoints <- list(
  lower = cbind(X1 = c(0, 1, 4), X2 = c(0, 1, 4)),
  upper = cbind(X1 = c(2, 3, 5), X2 = c(2, 3, 5)))
ggInterval_overlap(endpoints, labels = c("A", "B", "C"))
attr(ggInterval_overlap(endpoints), "interval_diagnostics")$overlap

Radar plot for symbolic data

Description

Visualize interval-valued and mixed symbolic data with a radar-style display. Interval-valued variables are represented through their lower and upper bounds, while modal multivalued variables can be shown with stacked bars. When type = "quantile", the function pools the lower and upper endpoints of each interval-valued variable and displays bands defined by adjacent internal empirical quantiles. Each axis is normalized over its retained quantile range.

Usage

ggInterval_radarplot(data=NULL,layerNumber=3,
inOneFig=TRUE,showLegend=TRUE,showXYLabs=FALSE,
plotPartial=NULL,
alpha=0.5,
base_circle=TRUE,
base_lty=2,
addText=TRUE,
type="default",
quantileNum=4,
Drift=0.5,
addText_modal=TRUE,
addText_modal.p=FALSE)

Arguments

data

A ggInterval object. It can also be either RSDA object or classical data frame(not recommended),which will be automatically convert to ggInterval data.

layerNumber

Number of concentric guide layers in the radar display.

inOneFig

Logical. If TRUE, draw all selected observations in one figure. Otherwise, generate separate figures for the selected observations.

showLegend

Logical. Whether to show the legend.

showXYLabs

Logical. Whether to show the x- and y-axis labels.

plotPartial

Numeric vector giving the row indices to plot. If NULL, all observations are used. This argument is ignored when type = "quantile" because the quantile plot summarizes all observations.

alpha

Alpha transparency for filled elements.

base_circle

Logical. If TRUE, add inner guide circles.

base_lty

Line type used in the base figure.

addText

Logical. Whether to add interval-valued labels to the plot.

type

Radar representation. Use "default" for polygon intervals, "rect" for rectangle intervals, or "quantile" for the quantile-radar display.

quantileNum

Integer from 2 to 10 controlling the internal quantile grid when type = "quantile". A value of q produces q+1 adjacent quantile bands; see Details.

Drift

Drift term controlling where the radar values begin.

addText_modal

Logical. Whether to add labels for modal multivalued variables.

addText_modal.p

Logical. Whether to add modal percentages.

Details

For q = quantileNum, the quantile display pools all lower and upper endpoints for each variable. It retains empirical quantiles at k/(q+3), for k=1,\ldots,q+2, rounds them to two decimal places, and pairs adjacent quantiles to form q+1 bands. Each radar axis is normalized over this retained quantile range. The bands summarize the relative spacing of pooled-endpoint quantiles, not distributions within individual intervals or nested central-coverage intervals. They are not confidence bands, and the normalized axes do not directly compare absolute locations or spreads across variables.

Examples


# must specify plotPartial to the rows you want to plot
Environment.n <- Environment[, 5:17]
ggInterval_radarplot(Environment.n,
  plotPartial = 2,
  showLegend = FALSE,
  base_circle = TRUE,
  base_lty = 2,
  addText = FALSE
) +
  labs(title = "") +
  scale_fill_manual(values = c("gray50")) +
  scale_color_manual(values = c("red"))

ggInterval_radarplot(Environment,
  plotPartial = 2,
  showLegend = FALSE,
  base_circle = FALSE,
  base_lty = 1,
  addText = TRUE,
  type = "rect"
) +
  labs(title = "") +
  scale_fill_manual(values = c("gray50")) +
  scale_color_manual(values = c("gray50"))

ggInterval_radarplot(
  facedata,
  base_circle = FALSE,
  base_lty = 1,
  type = "quantile",
  quantileNum = 5,
  showLegend = TRUE,
  Drift = 0
) +
  scale_fill_brewer(palette = "Greys") +
  labs(title = "", fill = "Quantiles")



Scatterplot matrix for interval-valued data

Description

Visualize all continuous interval-valued variables with a matrix of pairwise interval scatterplots. Each off-diagonal panel shows interval rectangles for one variable pair, whereas each diagonal panel displays the variable name. This function automatically filters out non-interval variables and plots all remaining continuous interval variables, so explicit x and y mappings are not required. It is not recommended to apply the function to too many variables because the full pairwise matrix becomes computationally expensive and visually crowded.

Usage

ggInterval_scatterMatrix(data = NULL, mapping = aes(NULL),
showLegend = FALSE, borderLinewidth = 0.08)

Arguments

data

A ggInterval object. It can also be either RSDA object or classical data frame,which will be automatically convert to ggInterval data.

mapping

Set of aesthetic mappings created by aes() or aes_(). If specified and inherit. aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping.

showLegend

whether show the legend.

borderLinewidth

Numeric border width used for the interval rectangles.

Value

Return a ggplot2 object.

Examples

mydata <- ggInterval::facedata
ggInterval_scatterMatrix(mydata[, 1:3])
ggInterval_scatterMatrix(
  mydata[, 1:3],
  aes(fill = "black", alpha = 0.2),
  borderLinewidth = 0.15
)

Scatter plot for two continuous interval variables

Description

Visualize the distribution of two continuous interval-valued variables with rectangles whose widths and heights represent the corresponding intervals.

Usage

ggInterval_scatterplot(data = NULL,mapping = aes(NULL),
showLabels = TRUE, labelSize = 3,
labelPosition = "topright", labelNudgeX = 0, labelNudgeY = 0,
checkOverlap = FALSE, ...)

Arguments

data

A ggInterval object.It can also be either RSDA object or classical data frame, which will be automatically convert to ggInterval data.

mapping

Set of aesthetic mappings created by aes() or aes_(). If specified and inherit. aes = TRUE (the default), it is combined with the default mapping at the top level of the plot. You must supply mapping if there is no plot mapping. Existing default rectangle mappings take precedence over duplicated user mappings. For a constant rectangle transparency, supply alpha = 0.2 outside aes() through ....

showLabels

Logical. If TRUE, add row labels to the rectangles.

labelSize

Numeric text size used when showLabels = TRUE.

labelPosition

Character label position used when showLabels = TRUE. One of "topright", "topleft", "bottomright", or "bottomleft".

labelNudgeX

Numeric horizontal adjustment applied to label positions.

labelNudgeY

Numeric vertical adjustment applied to label positions.

checkOverlap

Logical. Passed to geom_text() to suppress overlapping labels when needed.

...

Others in ggplot2.

Value

Return a ggplot2 object.

Examples

Subjects <- substr(rownames(facedata), 1, 3)
ggInterval_scatterplot(facedata, aes(x = AD, y = BC))
ggInterval_scatterplot(
  facedata,
  aes(x = AD, y = BC, fill = Subjects),
  showLabels = TRUE,
  labelSize = 2.6,
  labelPosition = "topright",
  labelNudgeX = 0.8,
  labelNudgeY = 0.15,
  checkOverlap = TRUE,
  col = "black"
)
p <- ggInterval_scatterplot(facedata[1:10, ], aes(x = AD, y = BC))
p + scale_fill_manual(
  labels = rownames(facedata)[1:10],
  values = rainbow(10),
  name = "Group"
)

iris.i data example

Description

iris.i interval data example.

Usage

data(iris.i)

Format

An object of class data.frame (inherits from symbolic_tbl) with 3 rows and 4 columns.

Examples

data(iris.i)
ggInterval_indexplot(iris.i, aes(x = Sepal.Length))

mtcars.i data example

Description

mtcars.i interval and modal data example.

Usage

data(mtcars.i)

Format

An object of class symbolic_tbl (inherits from tbl_df, tbl, data.frame, symbolic_tbl) with 5 rows and 11 columns.

Examples

data(mtcars.i)
ggInterval_indexplot(mtcars.i, aes(x = mpg))

mushroom data example

Description

mushroom interval data example.

Usage

data(mushroom)

Format

An object of class tbl_df (inherits from tbl, data.frame, symbolic_tbl) with 23 rows and 3 columns.

Source

Adapted from RSDA::mushroom; see https://CRAN.R-project.org/package=RSDA.

References

Billard, Lynne and Diday, Edwin (2006). Symbolic Data Analysis: Conceptual Statistics and Data Mining. Chichester, UK: John Wiley and Sons.

Examples

data(mushroom)

ggInterval_scatterplot(mushroom, aes(x = Cap.Widths, y = Stipe.Lengths))


oils data example

Description

oils interval data example.

Usage

data(oils)

Format

An object of class symbolic_tbl (inherits from tbl_df, tbl, data.frame) with 8 rows and 4 columns.

Source

Adapted from RSDA::oils; see https://CRAN.R-project.org/package=RSDA.

References

Cazes, Pierre; Chouakria, Assia; Diday, Edwin; and Schektman, Youri (1997). Extension de l'analyse en composantes principales a des donnees de type intervalle. Revue de Statistique Appliquee, 45(3), 5–24.

Examples

data(oils)

ggInterval_scatterplot(oils, aes(x = GRA, y = IOD))


scale for symbolic data table

Description

scale for symbolic data table

Usage

scale(x, ...)

## Default S3 method:
scale(x, center = TRUE, scale = TRUE, ...)

## S3 method for class 'symbolic_tbl'
scale(x, ...)

## S3 method for class 'symbolic_interval'
scale(x, ...)

Arguments

x

A symbolic table, symbolic interval vector, or numeric object.

...

Used by other R function.

center

same as base::scale, either a logical value or numeric-alike vector of length equal to the number of columns of x, where nmeric-alike means that as.numeric(.) will be applied successfully if is.numeric(.) is not true.

scale

same as base::scale, either a logical value or a numeric-alike vector of length equal to the number of columns of x.

Details

For each interval column, scale.symbolic_tbl pools its n lower and n upper endpoints and standardizes these 2n values using base scale, with centering and scaling both TRUE. scale.symbolic_interval transforms each endpoint by (endpoint - mean(x)) / sd(x), where mean and sd are the symbolic-interval methods dispatched for x (with ggInterval loaded, sd is this package's Billard formula). The center and scale arguments are honoured only by the default (numeric) method.

Value

For a symbolic table, a ggInterval object; use $intervalData to access the scaled data. Non-interval columns pass through unchanged. For a symbolic interval vector, a symbolic interval.

Examples


#For all interval-valued
scale(facedata)

#For both interval-valued and modal multi-valued
scale(mtcars.i)


Generic function for the standard deviation

Description

This function compute the symbolic standard deviation.

Usage

sd(x, ...)

## Default S3 method:
sd(x, na.rm = FALSE, ...)

## S3 method for class 'symbolic_tbl'
sd(
  x,
  method = c("billard", "centers", "interval", "B", "BD", "BG"),
  na.rm = FALSE,
  ...
)

## S3 method for class 'symbolic_interval'
sd(
  x,
  method = c("billard", "centers", "interval", "B", "BD", "BG"),
  na.rm = FALSE,
  ...
)

Arguments

x

First symbolic variables.

...

As in R sd function.

na.rm

As in R sd function.

method

The method to use.

Details

Supported interval-valued methods are:

Value

Return a real number.

References

Bertrand, Patrice and Goupil, Francoise (2000). Descriptive Statistics for Symbolic Data. In Hans-Hermann Bock and Edwin Diday (eds.), Analysis of Symbolic Data, pp. 106–124. Berlin and Heidelberg: Springer.

Billard, Lynne and Diday, Edwin (2006). Symbolic Data Analysis: Conceptual Statistics and Data Mining. Chichester, UK: John Wiley and Sons.

Billard, Lynne (2008). Sample covariance functions for complex quantitative data. In Proceedings of the World IASC Conference, pp. 157–163, Yokohama, Japan.


Synthetic financial low-high intervals

Description

A 62-observation subset of the randomly generated TTR::ttrc series, with dates in January–March 1985. The data do not represent an actual security. Each row retains a low-high interval and the auxiliary columns used in the interval-valued line-plot example.

Usage

data("stock.data.LH")

Format

A symbolic_tbl with 62 rows and seven columns:

V1

A symbolic_interval column with lower endpoint Low and upper endpoint High.

Date

Date labels, from 1985-01-02 to 1985-03-29.

Close

Synthetic closing prices.

Low

Synthetic daily low prices, retained for reconstruction.

High

Synthetic daily high prices, retained for reconstruction.

Month

A factor with levels Jan, Feb, and Mar.

Day

Integer day of month, used as the horizontal coordinate.

Details

There are 22, 19, and 21 observations in January, February, and March, respectively. The interval centers are the averages of Low and High; they need not equal Close. The interval column is constructed with classic2sym(); the source columns are then attached with dplyr::bind_cols(). The result is a static symbolic table, so head(stock.data.LH) displays the intervals and their accompanying columns together. TTR is needed to reconstruct the data, but not to load this stored subset.

Source

Adapted from TTR::ttrc in TTR version 0.24.4. TTR documents the source as randomly generated data for offline examples, not prices of an actual security. See https://CRAN.R-project.org/package=TTR.

See Also

ggInterval_lineplot, classic2sym

Examples

data("stock.data.LH")
head(stock.data.LH)
ggInterval_lineplot(stock.data.LH, aes(y = V1, x = Day), barWidth = 0.6) +
  geom_point(aes(y = Close), colour = "#D95F02") +
  facet_wrap(~Month, ncol = 1, scales = "free_y")

summary for symbolic data table

Description

summary for symbolic data table

Usage

summary(object, ...)

## Default S3 method:
summary(object, ...)

## S3 method for class 'symbolic_tbl'
summary(object, ...)

## S3 method for class 'symbolic_interval'
summary(object, ...)

## S3 method for class 'symbolic_modal'
summary(object, summary_fun = "mean", ...)

Arguments

object

an object for which a summary is desired.

...

additional arguments affecting the summary produced.

summary_fun

only works when the symbolic_modal class input, it determine which summary function be applied for each modal.

Value

Return a summary table.

Examples


#For all interval-valued
summary(facedata)

#For both interval-valued and modal multi-valued
summary(Environment)

summary(Environment$URBANICITY, summary_fun = "quantile")