0
我畫使用FactoMine R.我有一個像這樣的數據表一個MCA情節:MCA在FactoMineR
Met Aa Fn Pg Pi Tf Smut Ssob An Csput
C1 High N.S. N.S. N.S. High N.S. High High N.S.
C2 High N.S. Low High N.S. N.S. N.S. N.S. N.S.
C4 High High N.S. High N.S. N.S. High N.S. High
C6 N.S. N.S. High N.S. N.S. N.S. N.S. N.S. High
C9 Low Low Low Low Low High N.S. Low Low
C12 N.S. N.S. Low N.S. N.S. N.S. High N.S. High
###So I loaded my data
metabolites<-read.csv2('MCA24h_carbon.csv',dec='.')##all metabolites at 24h
###Named the column
metID<-metabolites$met
###Created a new matrix
newmet<-subset(metabolites,select=-c(Met))
### and the number of categories per variable
cats<- apply (newmet, 2, function(x) nlevels(as.factor(x)))
#and this is the output I get from the analysis:
structure(c(85L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 1L,
3L, 3L, 3L, 3L), .Names = c("Var", "Aa", "Fn", "Pg", "Pi", "Tf",
"Smut", "Ssob", "An", "Csput"))
這是我的第一個紅色的牌子......後來,我執行馬華只是爲了看看我會得到,這是代碼:
mca1=MCA(metabolites, graph=FALSE)
mca1$eig
mca1$var$coord
mca1$ind$coord
mca1_var_df=data.frame(mca1$var$coord, Variable=rep(names(cats), cats))
mca1_obs_df= data.frame(mca1$ind$coord)
接着,我會在控制檯以下:
Error in data.frame(mca1$var$coord, Variable = rep(names(cats), cats)) :
arguments imply differing number of rows: 269, 254
我很新,使用R (在1周內),但我有使用SAS的經驗...我不知道我在做什麼錯誤,爲什麼R將數據修復到上述結構(3L,3L,3L ...)有沒有人有任何想法如何進行?
您可以使用'na.omit()'函數刪除NA's – PAC
謝謝,它似乎工作:) –