[R] Error with repeat lines() in function
Uwe Ligges
ligges at statistik.uni-dortmund.de
Fri Sep 24 18:38:10 CEST 2004
Sean Davis wrote:
> Working on a toy example. I have run the debugger/browser on the
> example to find what line generates the error. However, I can't step
> into lines()--hence the question.
Hint:
options(error=recover)
Uwe Ligges
>
> Thanks for the help.
>
> Sean
>
> On Sep 24, 2004, at 12:18 PM, james.holtman at convergys.com wrote:
>
>>
>>
>>
>>
>> Can you provide an example. Have you run debug or browser on the
>> function?
>> __________________________________________________________
>> James Holtman "What is the problem you are trying to solve?"
>> Executive Technical Consultant -- Office of Technology, Convergys
>> james.holtman at convergys.com
>> +1 (513) 723-2929
>>
>>
>>
>> Sean Davis
>> <sdavis2 at mail.nih To: James
>> Holtman/CIMG/CVG at CVG
>> .gov> cc:
>> Subject: Re: [R] Error
>> with repeat lines() in function
>> 09/24/2004 12:11
>>
>>
>>
>>
>>
>>
>> James,
>>
>> The first lines command works without a problem (the error is in the
>> second lines command), and it is identical to the second. That is the
>> confusing part.
>>
>> Sean
>>
>> On Sep 24, 2004, at 12:03 PM, james.holtman at convergys.com wrote:
>>
>>>
>>>
>>>
>>>
>>> I would assume that the data that you are passing into the function in
>>> the
>>> 'apply' statement might not have the dimensionality that you assume;
>>> e.g.,
>>> z[5] or z[6] are out of range. Have you checked to make sure your
>>> data is
>>> correct?
>>> __________________________________________________________
>>> James Holtman "What is the problem you are trying to solve?"
>>> Executive Technical Consultant -- Office of Technology, Convergys
>>> james.holtman at convergys.com
>>> +1 (513) 723-2929
>>>
>>>
>>>
>>> Sean Davis
>>> <sdavis2 at mail.nih.gov To: r-help
>>> <r-help at stat.math.ethz.ch>
>>>
>>>> cc:
>>>
>>> Sent by: Subject: [R] Error
>>> with repeat lines() in function
>>> r-help-bounces at stat.m
>>> ath.ethz.ch
>>>
>>>
>>> 09/24/2004 11:48
>>>
>>>
>>>
>>>
>>>
>>>
>>> I have a function that does some plotting. I then add lines to the
>>> plot. If executed one line at a time, there is not a problem. If I
>>> execute the function, though, I get:
>>>
>>> Error in ans[[1]] : subscript out of bounds
>>>
>>> This always occurs after the second lines command, and doesn't happen
>>> with all of my data points (some do not have errors). Any ideas?
>>>
>>> Thanks,
>>> Sean
>>>
>>>
>>> function(x,annot,rat1,rat2,rf,...) {
>>> par(las=2)
>>> wh <- which(annot[,5]==x)
>>> xmax <- max(annot[wh,4])
>>> xmin <- min(annot[wh,3])
>>> chr <- annot[wh,2][1]
>>> wh.rf <- rf$chrom==as.character(chr) & rf$txStart>xmin &
>>> rf$txEnd<xmax
>>> par(mfrow=c(2,1))
>>> plot(annot[wh,3],rat1[wh],type="l",xlab="",ylab="log2
>>> Ratio",main=x,...)
>>> points(annot[wh,3],rat1[wh])
>>> apply(rf[wh.rf,],1,function(z) {
>>> browser()
>>> if (z[4]=="+") {
>>> color <- 'green'
>>> yoffset=1
>>> } else {
>>> color <- 'red'
>>> yoffset=-1
>>> }
>>>
>>> lines(list(x=c(z[5],z[6]),y=c(-2-yoffset/10,-2-yoffset/
>>> 10)),lwd=2,col=color)
>>>
>>> lines(list(x=c(z[5],z[6]),y=c(-2-yoffset/10,-2-yoffset/
>>> 10)),lwd=2,col=color)
>>> })
>>> abline(h=0,lty=2)
>>> }
>>>
>>> ______________________________________________
>>> R-help at stat.math.ethz.ch mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide!
>>> http://www.R-project.org/posting-guide.html
>>>
>>>
>>
>>
>>
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list