[R] error: subscript out of bounds?

jim holtman jholtman at gmail.com
Tue Jun 15 01:10:20 CEST 2010


You need to learn how to debug your program.  When the error occurs,
look at the value of the indices in the offending statement -- you
will find that the problem is subscript out of bounds.  Put the
following statement in your code:

 options(error=utils::recover)

and then do ?browser to learn how to use the browser for debugging.

On Mon, Jun 14, 2010 at 6:48 PM, Yesha Patel <turtysmail at gmail.com> wrote:
> Hi all,
>
> I want to get results for cox proportional hazards on SNP data. I'm trying
> to get HRs, CI's, & p-values for each individual SNP - this is represented
> by cov[,i]. When I run my code, I get the following error: subscript out of
> bounds. I don't know why I am getting this error.
>
> I have looked through the R logs, but nothing that has been previously
> suggested has helped so far. What am I doing wrong?
>
> DS3 = time variable, S3 = censor/event variable, cov = my dataset, which is
> in a data.frame format:
>
> *********************************************************
> CODE:
>
> test<-NULL
> bb=names(cov)
> col = dim(cov)[2]
> for(i in 19:col)
>  {
> mod=coxph(Surv(cov$DS3,cov$S3)~cov[,i]+AGE+sex,data=cov)
> aa<-summary(mod)
>  test<-rbind(test,c(bb[i],aa$coef[1,1],aa$coef[1,3],aa$coef[1,5],aa$conf.int
> [1,1],aa$conf.int[1,3],aa$conf.int
> [1,4],aa$coef[2,5],aa$coef[3,5],aa$coef[4,5]))
> }
> write.table(test,"result.txt",quote=F)
>
>
> Thanks!
> -CC
>
>        [[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 that you are trying to solve?



More information about the R-help mailing list