我有因素水平问题。我以为可以用 stringAsFactors=FALSE 解决,但它不起作用。
这pL
是一个包含 290 个元素的列表。我想定义一个空的 data.frame,而不是使用rbind
.
ttable <- data.frame(ID_REF=c(1,2,3,4,5,6), IDENTIFIER=c("ERN2", "HTR5A", "ACPP", "GNAO1", "HTR1F", "DNAH1"), GSM11708=c("<NA>", 1.994, "<NA>","<NA>","<NA>","<NA>"), GSM11735=c(0.18, "<NA>","<NA>","<NA>","<NA>","<NA>"))
pL <- list("GSTT4", "AHRR", "HAX1", "DNM1L", "MEIS1", "SLC17A3", "CES2", "MLL2", "IKBKB", "GSTA4")
gn <- data.frame(gn = character(0), stringsAsFactors=FALSE)
for(i in pL){
n <- nrow(subset(ttable, IDENTIFIER==i))
if (n < 1){
gn <- rbind(gn, i)
}
else{
for(j in 1:n){
gn <- rbind(gn, i)
}
}
}