From pgilbert@bank-banque-canada.ca  Fri Aug 21 17:19:13 1998
From: pgilbert@bank-banque-canada.ca (Paul Gilbert)
Date: Fri, 21 Aug 1998 12:19:13 -0400
Subject: couldn't find FUN
Message-ID: <98Aug21.122130edt.13441@mailgate.bank-banque-canada.ca>

The call to sweep in this function which was working in 0.62.2 is giving me
trouble in 62.3:

prcomponents <- function(x, center=TRUE, scale=TRUE, N=nrow(x)-1)
   {if (center) center <- apply(x,2,mean)
    else        center <- rep(0, ncol(x))
    if (scale)  scale  <- sqrt(apply(x,2,var))
    else        scale  <- rep(1, ncol(x))
    s <- svd(sweep(sweep(x,2, center),2, scale, FUN="/"))
    # remove anything corresponding to effectively zero singular values.
    rank <- sum(s$d > (s$d[1]*sqrt(.Machine$double.eps)))
    if (rank < ncol(x)) s$v <- s$v[,1:rank, drop=FALSE]
    s$d <- s$d/sqrt(max(1,N))

#   r <- list(sdev=s$d, proj=s$v,x=x %*% s$v, center=center, scale=scale)
    r <- list(sdev=s$d, proj=s$v, center=center, scale=scale)
    r
}

> data(crimes)
> prcomponents(crimes)
Error: couldn't find function "FUN"
> traceback()
[1] "eval(f)"
[2] "Ops.data.frame(x, aperm(array(STATS, dims[perm]), order(perm)), "
[3] "\t    ...)"
[4] "sweep(x, 2, center)"
[5] "sweep(sweep(x, 2, center), 2, scale, FUN = \"/\")"
[6] "svd(sweep(sweep(x, 2, center), 2, scale, FUN = \"/\"))"
[7] "prcomponents(crimes)"
>

Paul Gilbert

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


couldn't find FUN
Paul Gilbert