It is the first time I did this, so I hope it will be ok.
data.frame(
+ stringsAsFactors = FALSE,
+ Feces = c(2,2,2,2,2,2,2,2,2,2,2,
+ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2),
+ AgeM = c(".",".",".",".",".",".",
+ ".",".",".",".",".",".",".",".",".",".",".",".",
+ ".",".",".",".",".",".",".",".",".",".",".",
+ "."),
+ BMI = c(".",".",".",".",".",".",
+ ".",".",".",".",".",".",".",".",".",".",".",".",
+ ".",".",".",".",".",".",".",".",".",".",".",
+ "."),
+ BMIg = c(".",".",".",".",".",".",
+ ".",".",".",".",".",".",".",".",".",".",".",".",
+ ".",".",".",".",".",".",".",".",".",".",".",
+ "."),
+ SexeB = c("1","2","2","1","2","2",
+ "2","2","2","1","2","1","1","2","1","2","1","1",
+ "2","1","1","1","2","1","2","2","2","2","1",
+ "1"),
+ IMCpre = c(NA,NA,NA,NA,NA,NA,NA,NA,
+ NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,
+ NA,NA,NA,NA,NA,NA,NA,NA),
+ Actinobacteriota = c(0,4.79627142292859,
+ 9.6016686954278,0.936176624548455,0,12.7278699873943,
+ 9.51005614711799,1.02213897726925,10.097453103877,0,
+ 8.99062766006379,3.08587274405323,0,5.63618291089911,0,
+ 13.5912873400957,0,4.32560533648629,7.43524412465196,0,
+ 3.53047460027145,6.74181662096592,0,12.6723413631516,
+ 9.7319936987104,0,0,5.65681515304462,9.93354204340869,
+ 11.5864962134379),
+ Bacteroidota = c(0.657925332000861,
+ 11.9530060609906,11.4147052118096,11.7771698038494,
+ 10.8707735264602,1.87043750834246,8.09200612838812,9.96573966453783,
+ 6.90644434485874,9.84407789950601,11.2068550125141,
+ 13.6046681802104,18.3103991755461,10.7092795339724,0,
+ 9.0717371282259,0,12.9009377315435,0,11.0456078012402,0,
+ 13.9262721730943,12.6671414418058,9.9348574664441,
+ 15.2654151446842,0,0,10.4762813478554,4.59100543568373,
+ 1.37285468164623),
+ Firmicutes = c(10.4184352176161,
+ 9.92809532854541,8.10807531849262,9.96426105702548,10.2164295168172,
+ 10.2108898095977,14.9496645362555,12.4279094827263,
+ 13.8385838561187,10.2030092268829,8.94636646150262,
+ 13.6067270730954,9.57890009399775,11.2587041810381,
+ 13.4208543148522,13.4832527487818,15.9111191340145,
+ 9.93950422393423,9.69509972975999,9.44094838227359,
+ 12.1799394809243,12.9659646102721,9.65683671005289,11.3009568477833,
+ 15.1471309977389,11.562512117246,15.5345202733844,
+ 9.89413391745394,11.7486561096556,9.96493309583661),
+ Proteobacteria = c(9.96639324463059,
+ 10.7326091003568,9.50399644810617,11.3487214589489,9.80382427742247,
+ 9.96339257345624,12.889066497652,11.7869768971523,
+ 9.78469554927908,6.37330162190131,10.6896756986345,
+ 9.95638975394507,7.89008471152421,9.8952196458271,
+ 9.96722625883599,8.85766234354353,9.96722625883599,
+ 11.5162463003369,10.3510398028036,8.26191549968875,
+ 9.95193271220375,8.09440083858662,7.6056246505235,4.53659386809178,
+ 7.24414887432571,9.96722625883599,9.96722625883599,
+ 9.93523263596951,11.434053037473,10.7596237997704),
+ Id = as.factor(c("1004",
+ "1005","1006","1012","1013","1014","1020",
+ "1021","1028","1029","1030","1036","1037",
+ "1044","1052","1059","1060","1061","1067",
+ "1068","1069","1075","1076","1077","1083",
+ "1084","1085","1091","1092","1093")),
+ GDM = as.factor(c("1","0",
+ "0","1","0","0","1","0","1","0","0","1",
+ "0","1","1","1","1","1","1","1","1",
+ "1","0","1","1","0","0","1","0","0"))
This is the code I can't use
LIST <- matrix(nrow=4,ncol=5)
c1 <- c()
rowlme <- c()
c.upper <- c()
c.lower <- c()
phylumlme=matrix(nrow=30,ncol=3)
k=1
for(i in c(9:12)){
phylumlme=cbind(phylum_e[,1:2],phylum_e[,i])
str(phylum_e)
phylumlme <- as.data.frame(phylumlme)
colnames(phylumlme)=list(a="Id",b="GDM",c="Gen")
phylumlme$Id<-as.character(phylumlme$Id)
phylumlme$Id<-as.factor(phylumlme$Id)
phylumlme$GDM<-as.character(phylumlme$GDM)
phylumlme$GDM<-as.factor(phylumlme$GDM)
l <- lme(rank(Gen)~GDM, data=phylumlme, random=~1|Id, method="ML")
summary(l)
str(phylumlme)
Am <- Anova(l,type=2)[,3]
names(Am) <- rownames(Anova(l))
Sm <- summary(l)
tvalue <- Sm$tTable[,4]
pvalue <- Sm$tTable[,5]
c1$Pvalue=NA
c1$Contrast=NA
try(c1 <- contrast(l, list(GDM=c("0")), list(GDM=c("1")), type="average"), silent=T)
contrastResults <- c(c1$Contrast)
contrastPvalue <- c(c1$Pvalue)
c.upper <- c(c1$Upper)
c.lower <- c(c1$Lower)
row <- c(Am, contrastResults, contrastPvalue, c.lower, c.upper)
print(row)
LIST[k,] <- row
k=k+1
}
And this is the error code I received:
Error in LIST[k, ] <- row :
number of items to replace is not a multiple of replacement length
Thank you for your help !