summary_hyData.Rd
An alternative way to summarize non spectroscopic data (in @data
slot)
in a hyperSpec
object.
summary_hyData(object, ...)
# S3 method for default
summary_hyData(object, ...)
# S3 method for hyperSpec
summary_hyData(sp, ..., unique_ID = FALSE)
an object for which a summary is desired.
further parameters to be passed to function summary
.
hyperSpec
object.
(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.
A table with summary statistics.
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".
library(spHelper)
library(pander)
# Summary of "hyperSpec" object
summary_hyData(Spectra2)
#> Warning: Function 'chk.hy' is deprecated.
#> Use function 'assert_hyperSpec' instead.
#> gr class
#> A:52 K :50
#> B:55 l :30
#> C:43 N :19
#> S1:51
# Summary of "hyperSpec" object + `pander` (useful if `knitr` is used)
summary_hyData(Spectra2) %>% pander
#> Warning: Function 'chk.hy' is deprecated.
#> Use function 'assert_hyperSpec' instead.
#>
#> --------------
#> gr class
#> ------ -------
#> A:52 K :50
#>
#> B:55 l :30
#>
#> C:43 N :19
#>
#> S1:51
#> --------------
#>
# ======= `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)`
#> Warning: Function 'chk.hy' is deprecated.
#> Use function 'assert_hyperSpec' instead.
#> --- Group --- --- Class ---
#> A:52 K :50
#> B:55 l :30
#> C:43 N :19
#> S1:51
#> --- 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
#> 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] range A B C
#> 2. class: --- Class --- [factor] range K N S1 l
#> 3. spc: [matrix, array501] range -6.421769 -4.649723 ... 447.9696
#> 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
#>
#> -------------------------------
#> Petal.Width Species
#> --------------- ---------------
#> Min. :0.100 setosa :50
#>
#> 1st Qu.:0.300 versicolor:50
#>
#> Median :1.300 virginica :50
#>
#> Mean :1.199 NA
#>
#> 3rd Qu.:1.800 NA
#>
#> Max. :2.500 NA
#> -------------------------------
#>
iris[,4:5] %>% summary_hyData %>% pander
#>
#> -------------------------------
#> Petal.Width Species
#> --------------- ---------------
#> Min. :0.100 setosa :50
#>
#> 1st Qu.:0.300 versicolor:50
#>
#> Median :1.300 virginica :50
#>
#> Mean :1.199
#>
#> 3rd Qu.:1.800
#>
#> Max. :2.500
#> -------------------------------
#>