Functions show(), print(), summary(), and as.character() calculate and show a basic summary of a hyperSpec object.

# S4 method for hyperSpec
show(object)

# S4 method for hyperSpec
print(x, range = FALSE, include = "main", ...)

# S4 method for hyperSpec
summary(object, ..., include = "all", range = TRUE)

# S4 method for hyperSpec
as.character(
  x,
  digits = getOption("digits"),
  range = FALSE,
  max.print = 5,
  shorten.to = c(2, 1),
  include = c("all", "main", "wl", "data")
)

Arguments

object, x

A hyperSpec object.

range

Should the values be indicated as a range (from the smallest to the largest value) rather than as first and last elements?

include

Character vector that contains at least one (but usually several) of "all", "main","wl", or "data":

  • "all": the same as c("main", "wl", "data").

  • "main": the output includes the number of spectra, as well as the number rows an columns in @data field of hyperSpec object.

  • "wl": the output includes the summary of @wavelength field.

  • "data: the output includes the summary of each column in @data field.

...

print() and summary() hand further arguments to as.character().

digits

Number of digits handed over to format.

max.print

Maximum number of elements to be printed (of a variable).

shorten.to

If a vector is longer than max.print, only the first shorten.to[1] and the last shorten.to[2] elements are printed.

Value

After printing:

  • show() invisibly returns NULL,

  • print() and summary() invisibly returns x.

Function as.character() returns a character vector with summary of hyperSpec.

Details

Function as.character() does the main calculations. Functions show(), print(), and summary() use as.character() and print their results with different defaults:

  • show() prints the summary with the most basic information on hyperSpec object (number of rows, columns and spectra),

  • print()has the same default output show(),

  • summary() prints a bit larger summary of hyperSpec, that includes the number of rows, columns and spectra, the information on @wavelengths, lists column names of @data as well as a preview of the smallest and the largest values.

Examples

# show()
faux_cell # Implicitly prints the object. The same as show(faux_cell)
#> hyperSpec object
#>    875 spectra
#>    4 data columns
#>    300 data points / spectrum

show(faux_cell)
#> hyperSpec object
#>    875 spectra
#>    4 data columns
#>    300 data points / spectrum

# print()
print(faux_cell)
#> hyperSpec object
#>    875 spectra
#>    4 data columns
#>    300 data points / spectrum

print(faux_cell, include = "data")
#> data:  (875 rows x 4 columns)
#>    1. x: x position [numeric] -11.55 -10.55 ... 22.45 
#>    2. y: y position [numeric] -4.77 -4.77 ... 19.23 
#>    3. region:  [factor] matrix matrix ... matrix 
#>    4. spc: intensity (arbitrary units) [matrix, array300] 15 168 ... 93 

print(faux_cell, range = TRUE, include = "data")
#> data:  (875 rows x 4 columns)
#>    1. x: x position [numeric] range  -11.55 -10.55 ... 22.45 
#>    2. y: y position [numeric] range  -4.77 -3.77 ... 19.23 
#>    3. region:  [factor] range  cell    matrix  nucleus 
#>    4. spc: intensity (arbitrary units) [matrix, array300] range  0 1 ... 448 

# The difference between range = TRUE and FALSE
# is evident only when data is not sorted.
set.seed(1)
faux_cell_2 <- sample(faux_cell)
print(faux_cell_2, include = "data")
#> data:  (875 rows x 4 columns)
#>    1. x: x position [numeric] 18.45 1.45 ... -8.55 
#>    2. y: y position [numeric] 18.23 14.23 ... 2.23 
#>    3. region:  [factor] matrix matrix ... matrix 
#>    4. spc: intensity (arbitrary units) [matrix, array300] 72 136 ... 128 

print(faux_cell_2, range = TRUE, include = "data")
#> data:  (875 rows x 4 columns)
#>    1. x: x position [numeric] range  -11.55 -10.55 ... 22.45 
#>    2. y: y position [numeric] range  -4.77 -3.77 ... 19.23 
#>    3. region:  [factor] range  cell    matrix  nucleus 
#>    4. spc: intensity (arbitrary units) [matrix, array300] range  0 1 ... 448 

# summary()
summary(faux_cell)
#> hyperSpec object
#>    875 spectra
#>    4 data columns
#>    300 data points / spectrum
#> wavelength: Delta * tilde(nu)/cm^-1 [numeric] 602 606 ... 1798 
#> data:  (875 rows x 4 columns)
#>    1. x: x position [numeric] range  -11.55 -10.55 ... 22.45 
#>    2. y: y position [numeric] range  -4.77 -3.77 ... 19.23 
#>    3. region:  [factor] range  cell    matrix  nucleus 
#>    4. spc: intensity (arbitrary units) [matrix, array300] range  0 1 ... 448 

summary(faux_cell, include = c("wl", "data"))
#> wavelength: Delta * tilde(nu)/cm^-1 [numeric] 602 606 ... 1798 
#> data:  (875 rows x 4 columns)
#>    1. x: x position [numeric] range  -11.55 -10.55 ... 22.45 
#>    2. y: y position [numeric] range  -4.77 -3.77 ... 19.23 
#>    3. region:  [factor] range  cell    matrix  nucleus 
#>    4. spc: intensity (arbitrary units) [matrix, array300] range  0 1 ... 448 

as.character(faux_cell)
#>  [1] "hyperSpec object"                                                        
#>  [2] "   875 spectra"                                                          
#>  [3] "   4 data columns"                                                       
#>  [4] "   300 data points / spectrum"                                           
#>  [5] "wavelength: Delta * tilde(nu)/cm^-1 [numeric] 602 606 ... 1798 "         
#>  [6] "data:  (875 rows x 4 columns)"                                           
#>  [7] "   1. x: x position [numeric] -11.55 -10.55 ... 22.45 "                  
#>  [8] "   2. y: y position [numeric] -4.77 -4.77 ... 19.23 "                    
#>  [9] "   3. region:  [factor] matrix matrix ... matrix "                       
#> [10] "   4. spc: intensity (arbitrary units) [matrix, array300] 15 168 ... 93 "

as.character(faux_cell, include = c("wl", "data"))
#> [1] "wavelength: Delta * tilde(nu)/cm^-1 [numeric] 602 606 ... 1798 "         
#> [2] "data:  (875 rows x 4 columns)"                                           
#> [3] "   1. x: x position [numeric] -11.55 -10.55 ... 22.45 "                  
#> [4] "   2. y: y position [numeric] -4.77 -4.77 ... 19.23 "                    
#> [5] "   3. region:  [factor] matrix matrix ... matrix "                       
#> [6] "   4. spc: intensity (arbitrary units) [matrix, array300] 15 168 ... 93 "