jerome@hivnet.ubc.ca
2003-Jul-15 08:22 UTC
[Rd] "na.action" parameter in princomp() (PR#3481)
Full_Name: Jerome Asselin Version: 1.7.1 OS: Red Hat Linux 7.2 Submission from: (NULL) (24.77.125.119) Setting the parameter na.action=na.omit should remove incomplete records in princomp. However this does not seem to work as expected. See example below. Sincerely, Jerome Asselin data(USArrests) princomp(USArrests, cor = TRUE) #THIS WORKS USArrests[1,3] <- NA princomp(USArrests, cor = TRUE, na.action=na.omit) #THIS FAILS! #Error in cov.wt(z) : x must contain finite values only
Peter Dalgaard BSA
2003-Jul-15 09:21 UTC
[Rd] "na.action" parameter in princomp() (PR#3481)
jerome@hivnet.ubc.ca writes:> Setting the parameter na.action=na.omit should remove > incomplete records in princomp. However this does not > seem to work as expected. See example below. > > Sincerely, > Jerome Asselin > > > data(USArrests) > princomp(USArrests, cor = TRUE) #THIS WORKS > > USArrests[1,3] <- NA > princomp(USArrests, cor = TRUE, na.action=na.omit) #THIS FAILS! > #Error in cov.wt(z) : x must contain finite values onlyYou're not reading the help page properly. na.action is for formula specification only: Usage: princomp(formula, data = NULL, subset, na.action, ...) princomp(x, cor = FALSE, scores = TRUE, covmat = NULL, subset = rep(TRUE, nrow(as.matrix(x))), ...) This works: princomp(~.,data=USArrests, cor = TRUE, na.action=na.omit) -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907
Prof Brian Ripley
2003-Jul-18 11:08 UTC
[Rd] "na.action" parameter in princomp() (PR#3481)
It should not: na.action is only a valid argument for the formula method,
Current R-devel says
Usage:
## S3 method for class 'formula':
princomp(formula, data = NULL, subset, na.action, ...)
## S3 method for class 'default':
princomp(x, cor = FALSE, scores = TRUE, covmat = NULL,
subset = rep(TRUE, nrow(as.matrix(x))), ...)
which may help you see where you misread.
Just apply na.omit to the matrix/data.frame argument directly.
On Tue, 15 Jul 2003 jerome@hivnet.ubc.ca wrote:
> Full_Name: Jerome Asselin
> Version: 1.7.1
> OS: Red Hat Linux 7.2
> Submission from: (NULL) (24.77.125.119)
>
>
>
> Setting the parameter na.action=na.omit should remove
> incomplete records in princomp. However this does not
> seem to work as expected. See example below.
>
> Sincerely,
> Jerome Asselin
>
>
> data(USArrests)
> princomp(USArrests, cor = TRUE) #THIS WORKS
>
> USArrests[1,3] <- NA
> princomp(USArrests, cor = TRUE, na.action=na.omit) #THIS FAILS!
> #Error in cov.wt(z) : x must contain finite values only
>
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
>
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595