Error in `[.data.frame`(Xtot, , quanti.sup, drop = FALSE) : undefined columns selected

1,009 views
Skip to first unread message

Julie Kelso

unread,
Jul 29, 2018, 7:47:16 PM7/29/18
to FactoMineR users
I ran many PCA and MCA from the example datasets successfully. Then I tried to run my own PCA.

I called in my data using the following code.
df9<- read.table("df8.csv",header=TRUE, sep=",", dec=".", row.names=1)

Then I tried to run
dompca = PCA(df9[,c(7:17,19,20)], quanti.sup=c(41), graph=T)

And got the error "undefined columns selected. It will run without quanti.sup but not with it. Is there something wrong with my colimn names?
Column 41 is a continuous numeric vector pDevelopedTotal.

I also trie to run as MCA without supplementary variables and got a different error

dompca = MCA(df9[,c(7:17,19,20)], graph=T)
 
produced the error 
Error in which(unlist(lapply(listModa, is.numeric))) : 
  argument to 'which' is not logical

I have pasted below the structure of my data.

Thank you.

> str(df9)
'data.frame': 79 obs. of  46 variables:
 $ Site            : Factor w/ 33 levels "1700","2300",..: 7 8 9 9 9 10 13 13 14 14 ...
 $ Date            : int  151123 140913 151128 140904 141125 140913 140904 151128 140904 151121 ...
 $ Watershed       : Factor w/ 4 levels "Jordan","Logan",..: 2 2 2 2 2 2 2 2 2 2 ...
 $ DOC             : num  0.7 0.89 0.6 0.33 0.53 1.14 0.43 1.02 1.08 0.65 ...
 $ TDN             : num  0.34 0.18 0.16 0.17 0.17 0.31 0.11 0.27 NA 0.19 ...
 $ abs254          : num  0.02 0.012 0.01 0.015 0.01 0.023 0.019 0.019 0.012 0.015 ...
 $ BIX             : num  0.776 0.747 0.769 0.724 0.769 ...
 $ HIX             : num  2.27 4.87 5.93 6.37 5.93 ...
 $ FI              : num  1.65 1.63 1.64 1.64 1.64 ...
 $ YFI             : num  0.746 0.745 0.698 0.685 0.698 0.733 0.67 0.76 0.68 0.675 ...
 $ PeakT           : num  0.0844 0.0557 0.0419 0.0551 0.0419 ...
 $ PeakC           : num  0.1014 0.0836 0.0641 0.0884 0.0641 ...
 $ TC              : num  0.831 0.667 0.639 0.639 0.639 ...
 $ pFmax1          : num  0.315 0.375 0.375 0.395 0.375 ...
 $ pFmax2          : num  0.266 0.292 0.29 0.312 0.29 ...
 $ pFmax3          : num  0.137 0.196 0.162 0.165 0.162 ...
 $ pFmax4          : num  0.283 0.136 0.173 0.128 0.173 ...
 $ Protein         : num  0.206 0.111 0.087 0.101 0.087 ...
 $ pProtein        : num  0.42 0.332 0.335 0.293 0.335 ...
 $ SUVA            : num  2.86 1.35 1.11 4.55 1.11 ...
 $ year            : int  2015 2014 2015 2014 2015 2014 2014 2015 2014 2015 ...
 $ GraphDescription: Factor w/ 3 levels "DOM","Lake_DOM",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ Endmember       : Factor w/ 2 levels "DOM","Source": 1 1 1 1 1 1 1 1 1 1 ...
 $ EndmemberAll    : Factor w/ 1 level "DOM": 1 1 1 1 1 1 1 1 1 1 ...
 $ Month           : Factor w/ 3 levels "Dec","Nov","Sep": 2 3 2 3 2 3 3 2 3 2 ...
 $ cave            : num  -26.3 -28.6 -22.5 -28.2 -27.6 ...
 $ dave            : num  -118 -144 -133 -201 -193 ...
 $ VSS             : num  0.941 1.044 3.06 0.873 0.807 ...
 $ Chla            : num  0.617 2.44 0.241 1.07 2.58 ...
 $ DataSource      : Factor w/ 3 levels "bigc2","dfn3_AllJR",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ DevelopedTotal  : num  1.848 1.713 0.114 0.114 0.114 ...
 $ pBarren         : num  0.000359 0.001633 0.009904 0.009904 0.009904 ...
 $ pCrops          : num  0.00642 0 0 0 0 ...
 $ pDeveloped      : num  0.00478 0.005143 0.000117 0.000117 0.000117 ...
 $ pDevelopedOpen  : num  0.01373 0.01199 0.00102 0.00102 0.00102 ...
 $ pForest         : num  0.609 0.714 0.716 0.716 0.716 ...
 $ pOpenWater      : num  6.07e-06 2.30e-04 3.24e-04 3.24e-04 3.24e-04 ...
 $ pPasture        : num  0.01382 0.00386 0 0 0 ...
 $ pScrubGrassland : num  0.352 0.263 0.273 0.273 0.273 ...
 $ pWetland        : num  0.001692 0.000473 0.001361 0.001361 0.001361 ...
 $ pDevelopedTotal : num  0.01851 0.01714 0.00114 0.00114 0.00114 ...
 $ TotalArea       : int  825650 230263 77223 77223 77223 64543 234731 234731 230263 230263 ...
 $ HumanImpact     : num  1.868 1.717 0.114 0.114 0.114 ...
 $ HumImpFactor    : Factor w/ 2 levels "High","Low": 2 2 2 2 2 2 2 2 2 2 ...
 $ HumImpFactorjr  : Factor w/ 3 levels "High","Low","WWTPinfluenced": 2 2 2 2 2 2 2 2 2 2 ...
 $ HumImpFactor900 : Factor w/ 3 levels "High","Low","WWTPinfluenced": 2 2 2 2 2 2 2 2 2 2 ...

François Husson

unread,
Jul 30, 2018, 1:50:01 PM7/30/18
to factomin...@googlegroups.com
Hi

In your line of code, you have only 13 variables (the lentgh of c(7:17,19,20)). So quanti.sup can only be between 1 to 13.
And variables are quantitative so you cannot use MCA.

FH
--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "FactoMineR users".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse factominer-use...@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.

--
Francois Husson
Department Statistics & Computer science
AGROCAMPUS OUEST
65 rue de St-Brieuc - 35042 RENNES
Tel: +33 2 23 48 58 86
http://www.agrocampus-ouest.fr/math/husson
Reply all
Reply to author
Forward
0 new messages