# create a completely empty NMF object (i.e. 0 features, 0 basis components, 0 samples)
new('NMFstd')
# create a NMF object based on one random matrix: the missing matrix is deduced
# Note this only works when using factory method NMF
n <- 50; r <- 3;
w <- matrix(runif(n*r), n, r)
newNMF(W=w)
# create a NMF object based on random (compatible) matrices
p <- 20
h <- matrix(runif(r*p), r, p)
newNMF(W=w, H=h)
# create a NMF object based on incompatible matrices: generate an error
h <- matrix(runif((r+1)*p), r+1, p)
new('NMFstd', W=w, H=h)
# same thing using the factory method: dimensions are corrected and a warning
# is thrown saying that the dimensions used are reduced
newNMF(W=w, H=h)
# apply default NMF algorithm to a random target matrix
V <- matrix(runif(n*p), n, p)
nmf(V, r)
Run the code above in your browser using DataLab