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

后端 未结 2 995
夕颜
夕颜 2020-12-15 04:28

I am using the function prcomp to calculate the first two principal components. However, my data has some NA values and therefore the function throws an error.

2条回答
  •  情深已故
    2020-12-15 04:45

    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)
    

提交回复
热议问题