[R] How to replace NA with zero (0)

Christopher Kelvin chris_kelvin2001 at yahoo.com
Thu May 3 17:43:17 CEST 2012


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



More information about the R-help mailing list