| bind | R Documentation |
The former difficulties with binding S4 objects
are resolved since R version 3.2.0 and cbind and rbind now work as intended and
expected for hyperSpec objects.
cbind2 binds the spectral matrices of two hyperSpec objects by column. All columns
besides spc with the same name in x@data and y@data must have the same
elements. Rows are ordered before checking.
bind(
direction = stop("direction ('c' or 'r') required"),
...,
wl.tolerance = hy.getOption("wl.tolerance")
)
## S3 method for class 'hyperSpec'
cbind(...)
## S3 method for class 'hyperSpec'
rbind(...)
## S4 method for signature 'hyperSpec,hyperSpec'
cbind2(x, y)
## S4 method for signature 'hyperSpec,missing'
cbind2(x, y)
## S4 method for signature 'hyperSpec,hyperSpec'
rbind2(x, y, wl.tolerance = hy.getOption("wl.tolerance"))
## S4 method for signature 'hyperSpec,missing'
rbind2(x, y, wl.tolerance)
direction |
"r" or "c" to bind rows or columns |
... |
The Alternatively, one list of |
wl.tolerance |
|
x, y |
|
Therefore, calling rbind.hyperSpec and
cbind.hyperSpec is now depecated: cbind and rbind should now be called
directly.
However, in consequence it is no longer possible to call cbind or rbind with a
list of hyperSpec objects. In that case, use bind or do.call (see example).
bind does the common work for both column- and row-wise binding.
a hyperSpec object, possibly with different row order (for
bind ("c", ...{}) and cbind2).
You might have to make sure that the objects either all have or all do not have rownames and/or colnames.
C. Beleites
rbind2, cbind2
rbind, cbind
merge and collapse for combining objects that do not share spectra
or wavelengths, respectively.
chondro
bind ("r", chondro, chondro)
rbind (chondro, chondro)
cbind (chondro, chondro)
bind ("r", list (chondro, chondro, chondro))
x <- chondro[,, 600 : 605]
x$a <- 1
x@data <- x@data[, sample (ncol (x), ncol (x))] # reorder columns
y <- chondro [nrow (chondro) : 1,, 1730 : 1750] # reorder rows
y$b <- 2
cbind2 (x, y) # works
y$y[3] <- 5
try (cbind2 (x, y)) # error
# list of hyperSpec objects
lhy <- list (flu, flu)
do.call ("rbind", lhy)
bind ("r", lhy)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.