0
$\begingroup$

I have a dataset with 30 columns and 538 rows and I tried to run the prcomp, but it turns out it does not work with missing values and I can't use the na.omit because I would end up with one row only and that's useless for this purpose.

This is just the head of the df. Note that the first column is useless and I wanted to sort by group in the PCA plot. The dataset is avaliable here.

specimen    group   total_length    max_w   n_prog  ceph_pedun_L    bothrid_L   bothrid_W   n_loculi    n_transv_septa  stalk_L stalk_W prog_max_W  term_seg_L  term_seg_L  ratio_term_seg  term_seg_SA pore_pst_mrgn   percent_ prog_L n_progl_LgrW    n_mat_segs  n_testes    testes_L    testes_W    length_tst_field    term_c_sac_L    term_c_sac_W    ovary_L Ov_ratio_prog   OV_max_W
RN04_62_1   brooksi 6                                           820 240                         7               190 120 320     
RN04_62_2   brooksi 7.5                                         980 250                         8               240 140 430     
RN04_81_2   copianullum                                                                             8                               
RN04_81_3   paratrygonyi                                                                                8                               
RN04_81_4   fulbrighti                                                                              7                               
TO_05_80_5  fulbrighti  20                                          2000    310                         10              350 140 710     

I looked it up and there are a few ways to go around this problem:

  • run a probabilistic PCA
  • impute values to the NAs

I tried running PPCA with the pcaMethods package and it did not work.

Could anybody help me out? PS: I wanted to run the prcomp to get a biplot from the ggbiplot function afterwards. PS2: I moved my post from stackoverflow to here as it was suggested to me.

$\endgroup$
  • 1
    $\begingroup$ Why PPCA does not work? What is the error? First, do you replace the missing values by NA? $\endgroup$ – Jacky1 Nov 6 '15 at 16:02
  • $\begingroup$ There seems to be A LOT of missing values. One can work with them to a certain extent but if most of your table is empty, you shouldn't expect any meaningful result. There is no magic that can create these data for you. $\endgroup$ – amoeba Nov 6 '15 at 16:07
  • $\begingroup$ Jacky1, this is the error for PPCA: Error in [<-.data.frame(*tmp*, hidden, value = 0) : new columns would leave holes after existing columns $\endgroup$ – uller Nov 6 '15 at 21:23
  • $\begingroup$ amoeba, did you take a look at the full dataset? i feel like there are many parts of it which can be useful, but I would agree that I might get rid of some of the characters. $\endgroup$ – uller Nov 6 '15 at 21:24
  • $\begingroup$ and yes, I replaced the missing values by NA $\endgroup$ – uller Nov 6 '15 at 21:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.