I do not know how to use dput, i am attaching the txt file for the data
dput(any.object)
puts a structure of this object to console. You can copy it to your email
and anybody can copy it back to R.
Or you can transfer the structure to file see
?dput, ?dget
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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
this line is never true. There is no 2 in a c1.
Maybe you shall really tell us what is your intention with some simple
example.
Here is a subset of your file c1
my.c1 <- structure(list(HTN = structure(c(2L, 1L, 1L), .Label = c("",
"Y"), class = "factor"), HTN_FDR = structure(c(2L, 2L, 2L), .Label = c("",
"Y"), class = "factor"), Dyslipidemia = structure(c(2L, 1L, 2L
), .Label = c("", "Y"), class = "factor"), CAD = c(NA, NA, NA
), CAD_FDR = structure(c(2L, 2L, 1L), .Label = c("", "Y"), class =
"factor"),
Prior_MI = c(NA, NA, NA)), .Names = c("HTN", "HTN_FDR",
"Dyslipidemia",
"CAD", "CAD_FDR", "Prior_MI"), row.names = c("1", "5", "9"), class =
"data.frame")
Forget your complicated code and tell us what is you desired output?
Regards
Petr
for (j in 1:dim(c1)[2])
if(num_comp>0)
{
if (data$t1d_ptype[i] == "T1D" && c1[i ,j] == 2)
}
}
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.