here is the dump and the code once again, sorry for creating so much noise.
c1<-structure(list(HTN = structure(c(2L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L), .Label = c("", "Y"), class = "factor"), HTN_FDR = structure(c(2L, 
1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 
1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L), .Label = c("", "Y"), class = "factor"), 
    Dyslipidemia = structure(c(2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L), .Label = c("", "Y"), class = "factor"), CAD = structure(c(1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("", "Y"), class =
"factor"), 
    CAD_FDR = structure(c(2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 
    1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 
    1L), .Label = c("", "Y"), class = "factor"), Prior_MI = structure(c(1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("", "Y"), class =
"factor"), 
    t1d_ptype = structure(c(3L, 3L, 2L, 3L, 1L, 1L, 2L, 3L, 3L, 
    3L, 2L, 3L, 3L, 3L, 1L, 1L, 2L, 3L, 3L, 3L, 2L, 2L, 1L, 1L, 
    3L), .Label = c("Ctrl", "Ctrl_FDR", "T1D"), class = "factor")), .Names =
c("HTN", 
"HTN_FDR", "Dyslipidemia", "CAD", "CAD_FDR", "Prior_MI", "t1d_ptype"
), row.names = c(NA, 25L), class = "data.frame")

c2<-c1
any_comp<-NULL
for( i in 1:dim(c1)[1])
{
  num_comp<-0
  for (j in 1:dim(c1)[2])
     if (c1[i,j]==2) num_comp=num_comp+1      #"Y"=2
  for (j in 1:dim(c1)[2])
    if(num_comp>0)
    {
          if (data$t1d_ptype[i] == "T1D" && c1[i ,j] == 2) c2[i,j]<-"T1D_w"
        if (data$t1d_ptype[i] == "T1D" && c1[i, j] == 1)  c2[i,j]<-"T1D_oc"
        if(substr(data$t1d_ptype[i],1,4) == "Ctrl" && c1[i,j] == 2)
c2[i,j]<-"Ctrl_w"
        if (substr(data$t1d_ptype[i],1,4) == "Ctrl" && c1[i,j] == 1)
c2[i,j]<-"Ctrl_oc"
      }  
      else
       {
            if(data$t1d_ptype[i] == "T1D") c2[i,j]<-"T1D_noc"
            if(substr(data$t1d_ptype[i],1,4) == "Ctrl") c2[i,j]<-"Ctrl_noc"
       }
} 

--
View this message in context: 
http://r.789695.n4.nabble.com/Help-with-code-tp4218989p4222965.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to