##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (x, tol = sqrt(.Machine$double.eps))
{
dnx <- dimnames(x)
if (is.null(dnx))
dnx <- vector("list", 2)
s <- svd(x)
nz <- s$d > tol * s$d[1]
structure(if (any(nz))
s$v[, nz] %*% (t(s$u[, nz])/s$d[nz])
else x, dimnames = dnx[2:1])
}
Run the code above in your browser using DataLab