Learn R Programming

MRIaggr (version 1.1.5)

allocW: Allocate a neighbourhood matrix

Description

Allocate a neighbourhood matrix to a MRIaggr object.

Usage

"allocW"(object, type, overwrite = FALSE, verbose = optionsMRIaggr("verbose")) <- value

Arguments

object
an object of class MRIaggr. REQUIRED.
value
a list containing the neighbourhood matrix and associated elements. list. See the details section. REQUIRED.
type
the type of element to be allocated. Can be "Wmatrix", "Wblocks" or "upper". REQUIRED.
overwrite
if an element with the same name is already stored in object@ls_descStats, can it be overwritten ? logical.
verbose
should the execution of the function be traced ? logical.

Value

None.

Details

ARGUMENTS: Argument value must be a list containing named elements :
  • Element "Wmatrix" must be matrix or a sparse matrix.
  • Element "Wblocks" must be consistent with the output of the calcBlockW method.
  • Element "verbose" must be logical or NULL method.

FUNCTION: This method enable to store a neighbourhood matrix (type="Wmatrix"), a block decomposition of the matrix (type="Wblocks") and its format (type="upper") : entire matrix (NULL), upper-triagonal (TRUE) or lower-triagonal (FALSE).

See Also

calcW to compute the neighboring matrix. calcBlockW to decompose the neighboring matrix in independant blocks. selectW to extract the neighboring matrix or its related elements.

Examples

Run this code
## load a MRIaggr object
data("MRIaggr.Pat1_red", package = "MRIaggr")

## search for a neighbourhood matrix
# selectW(MRIaggr.Pat1_red) # no neighbourhood matrix

## compute the neighbourhood matrix
resW <- calcW(object = MRIaggr.Pat1_red, range = sqrt(2))

## store it
allocW(MRIaggr.Pat1_red, type = "Wmatrix") <- list(Wmatrix = resW$W)

## it is automatically performed when specifying update.object = TRUE
calcW(object = MRIaggr.Pat1_red, range = sqrt(2), update.object = TRUE, overwrite = TRUE)

Run the code above in your browser using DataLab