Learn R Programming

NMF (version 0.2.2)

nmfWrapper: Wrapping NMF Algorithms

Description

This function creates a wrapper function for calling the function nmf with a given NMF algorithm.

Usage

nmfWrapper(method, ..., .FIXED = FALSE)

Arguments

method
Name of the NMF algorithm to be wrapped. It should be the name of a registered algorithm as returned by nmfAlgorithm, or an NMF algorithm object (i.e. an instance of NMFStrateg
...
extra named arguments that define default values for any arguments of nmf or the algorithm itself.
.FIXED
a logical that indicates if the default arguments defined in ... must be considered as fixed, i.e. that they are forced to have the defined values and cannot be used in a call to the wrapper function, in which case, a warning about di

Value

  • a function with argument ... and a set of default arguments defined in ... in the call to nmfWrapper.

See Also

nmfAlgorithm, nmf

Examples

Run this code
# roxygen generated flag
options(R_CHECK_RUNNING_EXAMPLES_=TRUE)

# wrap Lee & Seung algorithm into a function
lee <- nmfWrapper('lee', seed=12345)
args(lee)

# test on random data
x <- rmatrix(100,20)
res <- nmf(x, 3, 'lee', seed=12345)
res2 <- lee(x, 3)
nmf.equal(res, res2)
res3 <- lee(x, 3, seed=123)
nmf.equal(res, res3)

stopifnot(nmf.equal(res, res2))
stopifnot( !nmf.equal(res, res3))

# argument 'method' has no effect
res4 <- lee(x, 3, method='brunet')
nmf.equal(res, res4)

stopifnot(nmf.equal(res, res4))

Run the code above in your browser using DataLab