Skip to content
Back to formatted view

Raw Message

Message-ID: <1324496667291-4222965.post@n4.nabble.com>
Date: 2011-12-21T19:44:27Z
From: 1Rnwb
Subject: Help with code
In-Reply-To: <1324408494591-4218989.post@n4.nabble.com>

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.