summary_hyData: [!] Summary statistics of non-spectroscopic data in...

View source: R/summary_hyData.R

summary_hyDataR Documentation

[!] Summary statistics of non-spectroscopic data in 'hyperSpec' objecet

Description

An alternative way to summarize non spectroscopic data (in @data slot) in a hyperSpec object.

Usage

summary_hyData(object, ...)

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

## S3 method for class 'hyperSpec'
summary_hyData(sp, ..., unique_ID = FALSE)

Arguments

object

an object for which a summary is desired.

...

further parameters to be passed to function summary.

sp

hyperSpec object.

unique_ID

(FALSE | character) either variable name that contain ID numbers (to select only the first rows with unique ID) or FALSE (default) to use all rows.

Details

If class of summarized object is:
- "hyperSpec", lablels of variables (slot @label) are used as headers of columns.

- not "hyperSpec", the function behaves in a similar way as function summary. The differences are indicated in section "Examples".

Value

A table with summary statistics.

See Also

summary

Examples


library(spHelper)
library(pander)


# Summary of "hyperSpec" object
 summary_hyData(Spectra2)


# Summary of "hyperSpec" object + `pander` (useful if `knitr` is used)
 summary_hyData(Spectra2) %>%  pander


# ======= `summary_hyData(sp)` vs `summary(sp$..)' vs `summary(sp)' ========
sp <- Spectra2
labels(sp) <- list(gr = "--- Group ---", class = "--- Class ---")

summary_hyData(sp)  # Column names are appropriate values of `labels(sp)`
#>   --- Group --- --- Class ---
#>    A:52          K :50
#>    B:55          l :30
#>    C:43          N :19
#>    S1:51

summary(sp$..)      # Column names are appropriate values of `colnames(sp)`
#>    gr     class
#>    A:52   K :50
#>    B:55   l :30
#>    C:43   N :19
#>    S1:51

summary(sp)         # Default summary of whole `hyperSpec` object
#>   hyperSpec object
#>   150 spectra
#>   3 data columns
#>   501 data points / spectrum
#>   wavelength:  [integer] 300 301 ... 800
#>   data:  (150 rows x 3 columns)
#>   1. gr: --- Group --- [factor] B B ... A
#>   2. class: --- Class --- [factor] N l ... S1
#>   3. spc:  [matrix501] 159.8996 139.9296 ... 12.11558

# ======= Summary of factor variables in a data frame ======================
# (if printed using function `pander` there are differences in column
# `Species` ):

iris[,4:5]  %>%  summary         %>%  pander
iris[,4:5]  %>%  summary_hyData  %>%  pander



GegznaV/spHelper documentation built on April 16, 2023, 1:42 p.m.