Skip to content
Prev 293505 / 398503 Next

How to replace NA with zero (0)

?Surv

time2: ending time of the interval for interval censored or counting
           process data only

and

w=Surv(r,t,type="interval2")
Warning message:
In Surv(r, t, type = "interval2") :
   Invalid interval: start>  stop, NA created

=>  r needs to be greater that t.
I can only agree with that.
On 12-05-03 05:18 PM, Steve Lianoglou wrote:

            
set.seed(1)
r1=runif(10)
set.seed(2)
t=runif(10)
w=Surv(r,t,type="interval2")

w1=w
w1[is.na(w)] = 0
w1
  [1] 0.00000000+             [0.37212390, 0.7023740] [0.57285336, 
0.5733263]
  [4] 0.00000000+             [0.20168193, 0.9438393] [0.89838968, 
0.9434750]
  [7] 0.00000000+             [0.66079779, 0.8334488] 0.00000000+
[10] [0.06178627, 0.5499837]

w2=w
w2[which(is.na(w2))] = 0
w2
  [1] [0.00000000, 0.1848823] [0.37212390, 0.7023740] [0.57285336, 
0.5733263]
  [4] [0.00000000, 0.1680519] [0.20168193, 0.9438393] [0.89838968, 
0.9434750]
  [7] [0.00000000, 0.1291590] [0.66079779, 0.8334488] [0.00000000, 
0.4680185]
[10] [0.06178627, 0.5499837]

Eloi