回复 第2楼 的 itellin:非常感谢,但是有个疑问,为什么我用for循环subset得不出结果呢,下面是我写的代码(思想还停留在C++,),
<br />
classify <- function(ACTG320_,Patient)<br />
{<br />
PatientID <- c(0)<br />
Date <- c(0)<br />
CD4_VLoad <- c(0)<br />
PatientAll <- data.frame(PatientID,Date,CD4_VLoad)<br />
print(PatientAll)<br />
for(i in 1:length(Patient))<br />
{<br />
for(j in 1:length(ACTG320_$PtID))<br />
{<br />
if(Patient[i] == ACTG320_$PtID[j])<br />
{<br />
rbind(PatientAll,list(ACTG320_$PtID[j],ACTG320_$CD4Date[j],ACTG320_$CD4Count_VLoad[j]))<br />
}<br />
}<br />
}<br />
return(PatientAll)<br />
}<br />
</p>