Hello,
?When i generate data with the code below there appear NA as part of the
generated data, i prefer to have zero (0) instead of NA on my data.
Is there a command i can issue to replace the NA with zero (0) even if it is
after generating the data??
Thank you
library(survival)
p1<-0.8;b<-1.5;rr<-1000
for(i in 1:rr){
r<-runif(45,min=0,max=1)
t<-rweibull(45,p1,b)
w=Surv(r,t,type="interval2")
x[1:45]<-(w[,1])
u<-x[1:45]
y[1:45]<-(w[,2])
v<-y[1:45]
}
w
u
v
Chris G
Researcher
Institute for Mathematical Research
UPM
On Thu, May 3, 2012 at 10:43 AM, Christopher Kelvin <chris_kelvin2001 at yahoo.com> wrote:> Is there a command i can issue to replace the NA with zero (0) even if it is after generating the data?Chris, I didn't try your example code, so this suggestion is far more general, but you might try something along the lines of: x[which(is.na(x))] <- 0 Best, James
On 04/05/12 03:43, Christopher Kelvin wrote:> Hello, > When i generate data with the code below there appear NA as part of the generated data, i prefer to have zero (0) instead of NA on my data. > Is there a command i can issue to replace the NA with zero (0) even if it is after generating the data?<SNIP> Just ***DON'T***. NAs and zeroes are completely different concepts. You will simply confuse everybody including yourself. cheers, Rolf Turner