On 17 May 2006, at 22:02, [EMAIL PROTECTED] wrote: > On Wed, 17 May 2006, [EMAIL PROTECTED] wrote: >> >> prcomp has a bug which causes following error >> >> Error in svd(x, nu = 0) : infinite or missing values in 'x' >> >> on a valid data set (no Infs, no missing values). The error is most >> likely >> caused by the zeros in data. > > Why do you say that? Without a reproducible example, we cannot judge > what > is going on. If you called prcomp with scale=TRUE on a matrix that > has a > completely zero (or constant) column, then this is a reasonable error > message.
Constant columns (which is a likely reason here) indeed become NaN after scale(), but the error message was: Error in svd(x, nu = 0) : infinite or missing values in 'x' and calling this 'reasonable' is stretching the limits of reason. However, in general this is "easy" to solve: scale() before the analysis and replace NaN with 0 (prcomp handles zeros). For instance, x <- scale(x) x[is.nan(x)] <- 0 prcomp(x) (and a friendly prcomp() would do this internally.) cheers, jari oksanen -- Jari Oksanen, Oulu, Finland ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
