Plot a summary of spectroscopic data in hyperSpec object by group. The summary statistic internally is generated by either function spStat or aggregate.

qplot_spStat(
  sp,
  by = stop("Argument 'by' is missing."),
  FUN = stop("Argument 'FUN' is missing."),
  Title = fCap(as.character(match.call()$FUN)),
  subTitle = NULL,
  All = FALSE,
  fixed.colors = All,
  All.color = "black",
  gr.color = c(hyGet_palette(sp), RColorBrewer::brewer.pal(8, "Dark2")),
  All.linetype = "dashed",
  gr.linetype = "solid",
  All.size = 1.1,
  gr.size = 0.8,
  legend.title = element_blank(),
  ...,
  add = FALSE
)

layer_spStat(
  sp,
  by = stop("Argument 'by' is missing."),
  FUN = stop("Argument 'FUN' is missing."),
  Title = fCap(as.character(match.call()$FUN)),
  subTitle = NULL,
  All = FALSE,
  ...,
  add = TRUE
)

Arguments

sp

Spectroscopic data (either a hyperSpec object or a matrix).

by

A grouping variable (either a vector or a variable name in sp).

FUN

A function that calculates one or several summary statistics.

Title

The main title of the plot.

subTitle

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

All

Logical. If TRUE, plot additional curve for a statistic of all spectra (.ALL), not divided to groups.

fixed.colors

- Logical. If TRUE, color scheme where .ALL is plotted as a black line is be used.

All.color

A line color for .ALL.

gr.color

Line colors (a vector) for each level in by.

All.linetype

A line type for .ALL.

gr.linetype

Line types (a vector) for each level in by.

All.size

A line width for .ALL.

gr.size

Line widths (a vector) for each level in by.

legend.title

A title for legend. Default is no title.

Value

A ggplot object. More details in package ggplot2.

Author

Vilmantas Gegzna

Examples



qplot_spStat(chondro,"clusters",mean)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'nrow': object 'chondro' not found
qplot_spStat(chondro,"clusters",mean,All=FALSE)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'nrow': object 'chondro' not found
qplot_spStat(chondro,"clusters",mean_sd,All=FALSE) + facet_grid(.~clusters)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'nrow': object 'chondro' not found

qplot_spStat(chondro,"clusters",median,All=FALSE, fixed.colors=FALSE)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'nrow': object 'chondro' not found
qplot_spStat(chondro,"clusters",median, "My Title")
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'nrow': object 'chondro' not found


# Make facets with fewer ticks on the x axis:
qplot_spStat(chondro,"clusters",mean_pm_sd) +
     facet_grid(.~clusters) +
     nTick_x(2)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'nrow': object 'chondro' not found


# Add as a layer:
qplot_spRange(chondro, "clusters") +
     layer_spStat(chondro,"clusters", mean, size = 1)
#> Error in hyGet_palette0(sp): object 'chondro' not found