[R] problem with ifelse
Christopher Kelvin
chris_kelvin2001 at yahoo.com
Wed May 30 16:01:16 CEST 2012
Dear all,
The code below is used to generate interval censored data but unfortunately there is an error with the ifelse which i am not able to rectify.
Can somebody help correct it for me.
Thank you
t<-rexp(20,0.2)
v<-c(0,m,999)
y<-function(t,v){
z<-numeric(length(t ((
s<-numeric(length(t ((
for(i in 1:length(t)){
for(j in 1:length(v-1))
{ ifelse ((t[i]>v[j] & t< v[j+1] ),{z[i]<-v[j];s[i]<-v[j+1]},NA)}}
return(cbind(z,s))}
y(t,v)
Chris Kelvin
Institute for Mathematical Research
UPM
More information about the R-help
mailing list