R function prcomp fails with NA's values even though NA's are allowed

£可爱£侵袭症+ 提交于 2019-11-29 05:29:55

Yeah, it looks like a "feature" (bug) that na.action is completely ignored unless you use the formula interface. This has been brought up before on the R Development list.

I think that this should be documented or flagged as a bug.

Just to be clear, this would work because it accesses the formula interface:

prcomp(~V1+V2, data=d, center = TRUE, scale = TRUE, na.action = na.omit)

Another solution if you're not willing to use formula interface is

prcomp(na.omit(d), center = TRUE, scale = TRUE)

which consist of applying na.omit directly to the data frame.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!