Plot amplitudes (a.k.a scores) of spectroscopic components grouped by categorical variable by. Amplitudes are provided as hyperSpec object.

qplot_kAmp(
  scores,
  Title = "Component amplitudes",
  subTitle = NULL,
  xLabel = labels(scores, ".wavelength"),
  yLabel = labels(scores, "spc"),
  by = "gr",
  palette = hyGet_palette(scores),
  add.violin = TRUE,
  add.jitter = FALSE,
  add.boxplot = TRUE,
  violin.alpha = 0.25,
  jitter.alpha = 0.3,
  jitter.size = 1
)

qplot_scores(..., by = NULL, add.violin = FALSE)

Arguments

scores

An object of class hyperSpec with factor scores, principal component scores, component amplitudes, etc.

Title

The main title for the plot.

subTitle

The second line of title, which will be smaller and and in italics.

xLabel

A label for abscisa (x) axis.

yLabel

A label for ordinate (y) axis.

by

A name of grouping variable. If NULL, all data is ploted. Default is by = "gr" for qplot_kAmp and by = NULL for qplot_scores.

palette

A color palette to be used in plotting. (...)

add.violin

Logical. If TRUE adds so called violin (i.e., symmetrical probarility density) plot. Default is TRUE for qplot_kAmp.

add.jitter

Logical. If TRUE adds jitter plot. Default is FALSE.

add.boxplot

Logical. If TRUE adds boxplot. Default is TRUE.

violin.alpha

Transperency of violin plot.

jitter.alpha

Transperency of jitter plot.

jitter.size

Point size in jitter plot.

...

(The same parameters as above).

Value

A ggplot object. More details in package ggplot2.

Details

Plots are drawn in this order: violin plot, jitter plot, boxplot.

Note

If more information on matrix decomposition/factorisation is needed it can be found here or here).

Author

Vilmantas Gegzna

Examples


data(Scores2)
qplot_kAmp(Scores2)
#> Warning: Function 'hyperSpec::chk.hy' is deprecated. 
#> Use function 'assert_hyperSpec' instead.
#> Error in dplyr::mutate(., row = row_number()):  In argument: `row = row_number()`.
#> Caused by error in `row_number()`:
#> ! could not find function "row_number"
qplot_scores(Scores2)
#> Warning: Function 'hyperSpec::chk.hy' is deprecated. 
#> Use function 'assert_hyperSpec' instead.
#> Error in dplyr::mutate(., row = row_number()):  In argument: `row = row_number()`.
#> Caused by error in `row_number()`:
#> ! could not find function "row_number"

data(Scores3)
qplot_kAmp(Scores3, by = "class")
#> Warning: Function 'hyperSpec::chk.hy' is deprecated. 
#> Use function 'assert_hyperSpec' instead.
#> Error in dplyr::mutate(., row = row_number()):  In argument: `row = row_number()`.
#> Caused by error in `row_number()`:
#> ! could not find function "row_number"

sp3 <- hyAdd_color(Scores3, "class")
qplot_kAmp(sp3, by = "class")
#> Warning: Function 'hyperSpec::chk.hy' is deprecated. 
#> Use function 'assert_hyperSpec' instead.
#> Error in dplyr::mutate(., row = row_number()):  In argument: `row = row_number()`.
#> Caused by error in `row_number()`:
#> ! could not find function "row_number"

p <- qplot_scores(Scores2, add.jitter = TRUE)
#> Warning: Function 'hyperSpec::chk.hy' is deprecated. 
#> Use function 'assert_hyperSpec' instead.
#> Error in dplyr::mutate(., row = row_number()):  In argument: `row = row_number()`.
#> Caused by error in `row_number()`:
#> ! could not find function "row_number"
p
#> function (x, wrap = panderOptions("p.wrap"), sep = panderOptions("p.sep"), 
#>     copula = panderOptions("p.copula"), limit = Inf, keep.trailing.zeros = panderOptions("keep.trailing.zeros"), 
#>     missing = panderOptions("missing"), digits = panderOptions("digits"), 
#>     round = panderOptions("round")) 
#> {
#>     attributes(x) <- NULL
#>     stopifnot(is.vector(x))
#>     stopifnot(all(sapply(list(wrap, sep, copula), function(x) is.character(x) && 
#>         length(x) == 1)))
#>     x.len <- length(x)
#>     if (x.len == 0) {
#>         return("")
#>     }
#>     stopifnot(x.len <= limit)
#>     w <- which(is.na(x))
#>     if (is.numeric(x)) {
#>         x <- round(x, digits = round)
#>         if (!keep.trailing.zeros) {
#>             x <- sapply(x, format, trim = TRUE, digits = digits, 
#>                 decimal.mark = panderOptions("decimal.mark"))
#>         }
#>         else {
#>             x <- format(x, trim = TRUE, digits = digits, decimal.mark = panderOptions("decimal.mark"))
#>         }
#>     }
#>     if (length(w) > 0) {
#>         x[w] <- missing
#>     }
#>     if (x.len == 1) {
#>         wrap(x, wrap)
#>     }
#>     else if (x.len == 2) {
#>         paste(wrap(x, wrap), collapse = copula)
#>     }
#>     else {
#>         paste0(paste(wrap(head(x, -1), wrap), collapse = sep), 
#>             copula, wrap(tail(x, 1), wrap))
#>     }
#> }
#> <bytecode: 0x0000022b08b62740>
#> <environment: namespace:pander>

p + theme_bw()
#> NULL