[R] Help with code

1Rnwb sbpurohit at gmail.com
Wed Dec 21 19:07:27 CET 2011


I do not know how to use dput, i am attaching the txt file for the data
http://r.789695.n4.nabble.com/file/n4222616/foo.txt foo.txt 

c1<-read.dlim('foo.txt')
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"
       }
}

this gives me whether the particular t1d_ptype has a specific complication
as well as there is another complication as well.

I will appreciate help very much.
thanks
sharad 

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



More information about the R-help mailing list