Re: [R] Is there a way to get R script line number

2017-04-07 Thread MacQueen, Don
Possible clarification/correction...(apologies in advance if I'm being 
redundant)

If I put the following four lines in a script whose file name is "junk.r":

log(3)
log(4)
log('a')
log(5)

then it generates an error message, as expected:

> source('junk.r')
Error in log("a") (from junk.r#3) : non-numeric argument to mathematical 
function

Note that the error message references the line number (correctly).

So there must be something somewhere that keeps track of the script's line 
numbers. Finding it, however, is more than I'm ready to tackle.

-Don


-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062


On 4/6/17, 12:30 PM, "R-help on behalf of Bert Gunter" 
<r-help-boun...@r-project.org on behalf of bgunter.4...@gmail.com> wrote:

I believe the answer is: No. "Line number" is an ambiguous concept.
Does it mean physical line on a display of a given width? a line of
code demarcated by e.g.  ; a step in the execution of script (that
might display over several physical lines?)

However, various IDE's have and display "line numbers," so you might
try researching whichever one that you use.

(Note: Correction/clarification requested if I am wrong on this).

-- Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Thu, Apr 6, 2017 at 11:59 AM, Brad P <bpsch...@gmail.com> wrote:
> Hello,
>
> Is there a way to get the current line number in an R script?
>
> As a silly example, if I have the following script and a function called
> getLineNumber (suppose one exists!), then the result would be 3.
>
> 1 # This is start of script
> 2
> 3 print( getLineNumber() )
> 4
> 5 # End of script
>
> Thanks for any ideas!
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Is there a way to get R script line number

2017-04-07 Thread William Michels via R-help
Hi Brad,

Some of the debugging functions may be of use. You can look at trace()
or setBreakpoint(). But I believe Bert is correct in saying your
concept of a "Line Number" and R's concept of a "Line Number" will
differ.

Finally, you can look at the function findLineNum(), which can be
called external to your source code file (not embedded as in your
example).

>?debug

HTH,

Bill

William J. Michels, Ph.D.



On Thu, Apr 6, 2017 at 12:30 PM, Bert Gunter <bgunter.4...@gmail.com> wrote:
> I believe the answer is: No. "Line number" is an ambiguous concept.
> Does it mean physical line on a display of a given width? a line of
> code demarcated by e.g.  ; a step in the execution of script (that
> might display over several physical lines?)
>
> However, various IDE's have and display "line numbers," so you might
> try researching whichever one that you use.
>
> (Note: Correction/clarification requested if I am wrong on this).
>
> -- Bert
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Thu, Apr 6, 2017 at 11:59 AM, Brad P <bpsch...@gmail.com> wrote:
>> Hello,
>>
>> Is there a way to get the current line number in an R script?
>>
>> As a silly example, if I have the following script and a function called
>> getLineNumber (suppose one exists!), then the result would be 3.
>>
>> 1 # This is start of script
>> 2
>> 3 print( getLineNumber() )
>> 4
>> 5 # End of script
>>
>> Thanks for any ideas!
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Is there a way to get R script line number

2017-04-06 Thread Bert Gunter
I believe the answer is: No. "Line number" is an ambiguous concept.
Does it mean physical line on a display of a given width? a line of
code demarcated by e.g.  ; a step in the execution of script (that
might display over several physical lines?)

However, various IDE's have and display "line numbers," so you might
try researching whichever one that you use.

(Note: Correction/clarification requested if I am wrong on this).

-- Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Thu, Apr 6, 2017 at 11:59 AM, Brad P <bpsch...@gmail.com> wrote:
> Hello,
>
> Is there a way to get the current line number in an R script?
>
> As a silly example, if I have the following script and a function called
> getLineNumber (suppose one exists!), then the result would be 3.
>
> 1 # This is start of script
> 2
> 3 print( getLineNumber() )
> 4
> 5 # End of script
>
> Thanks for any ideas!
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] Is there a way to get R script line number

2017-04-06 Thread Brad P
Hello,

Is there a way to get the current line number in an R script?

As a silly example, if I have the following script and a function called
getLineNumber (suppose one exists!), then the result would be 3.

1 # This is start of script
2
3 print( getLineNumber() )
4
5 # End of script

Thanks for any ideas!

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.