[Rd] "na.action" parameter in princomp() (PR#3481)
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Tue Jul 15 08:21:16 MEST 2003
jerome at 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 only
You'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 at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-devel
mailing list