[R] programming question
jim holtman
jholtman at gmail.com
Fri Oct 19 00:13:05 CEST 2007
I am not sure I understand your question. I get the following output
from your code and it does not look like act.surv.time is repeated:
> m
treat strata time censorTime act.surv.time censoring
[1,] 1 1 0.8331923 0.65472393 0.65472393 1
[2,] 1 1 0.3389548 0.35319727 0.33895477 0
[3,] 1 1 0.9163048 0.27026015 0.27026015 1
[4,] 1 1 1.1228471 0.99268406 0.99268406 1
[5,] 1 1 0.2782769 0.63349326 0.27827691 0
So what is the problem?
On 10/18/07, raymond chiruka <rtchiruka at yahoo.com> wrote:
> hie
> i'm tryimg to generate two survival data using the following code (I know its ugly ) but it seems to repeat two of the variables can any one tell me whats the porblem.
>
> n=20
> n1=n/2
> n2=n/4
> a11=1 ;a12=1.4 ;a21=16 ;a22=a12 * a21
> t1<-array(1,c(n1))
> t2<-array(2,c(n1))
> treatgrp=matrix(c(t1,t2))
> st11<-array(1,c(n2))
> st12<-array(2,c(n2))
> st21<-array(1,c(n2))
> st22<-array(2,c(n2))
> strata=matrix(c(st11,st12,st21,st22))
> time11=array(rweibull(n2,a11,1))
> time12=array(rweibull(n2,a12,1))
> time21=array(rweibull(n2,a21,1))
> time22=array(rweibull(n2,a22,1))
> time=matrix(c(time11, time12, time21, time22))
> censorTime=runif(n,0,1)
> m=cbind(treatgrp,strata,time,censorTime) .
> colnames(m)=c("treat","strata","time","censorTime")
>
> act.surv.time<-pmin(m[,"time"],m[,"censorTime"])
>
> m<-cbind(m,act.surv.time)
> m<-cbind(m,0)
> m[m[,3]>m[,4],6]<-1
> colnames(m)[6]<-"censoring"
> m
> act.surv.time is repeated at the end of the data frame.
>
> thanks
>
> __________________________________________________
>
>
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?
More information about the R-help
mailing list