아래의 루프를 만들어 테이블의 행과 일치하는 조건을 확인하십시오. 일치하면 rowname이 인쇄됩니다. 일치하지 않으면 아무 일도 일어나지 않습니다.테이블의 여러 행을 여러 조건과 일치 시키려면
condition <- c(0,0,1,1)
id <- apply(table, 1,
function(i) sum(i[1:length(table)] != condition)==0)
idd<-as.matrix(id)
for (i in 1:length(idd)){
if (idd[i] == TRUE) {
print(rownames(idd)[i])
}
}
> table
> [1] [2] [3] [4]
>1651838 1 1 0 0
>1653006 0 0 0 0
>1656415 0 0 0 1
>1657317 -1 0 0 0
내 질문은 : 여러 조건에 대해이 루프를 만들 수 있습니까? 예 :
condition <- c("0,0,0,0","0,0,0,1","0,0,1,0","0,1,0,0","1,0,0,0",
"0,0,1,1","1,1,0,0","0,1,1,0","1,0,0,1","1,0,1,0",
"0,1,0,1","1,0,1,1","1,1,0,1","1,1,1,0","0,1,1,1","1,1,1,1")
for(r in 1:length(condition)){
id <- apply(regulationtable, 1,
function(i) sum(i[1:length(regulationtable)] != condition[r])==0
)
idd<-as.matrix(id)
test<-list()
for (i in 1:length(idd)) {
if (idd[i] == TRUE) {
print(rownames(idd)[i])
}
test[[i]]<-matrix(idtest)
}
}
감사합니다.
http://stackoverflow.com/questions/5375642/venestiagram-create-list-of-venncounts –