Re: [R] error: subscript out of bounds?

From: jim holtman <jholtman_at_gmail.com>
Date: Mon, 14 Jun 2010 19:10:20 -0400

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?

______________________________________________
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.
Received on Mon 14 Jun 2010 - 23:12:27 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 15 Jun 2010 - 00:10:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive