[R] Is there a way to get R script line number
macqueen1 at llnl.gov
Sat Apr 8 00:19:08 CEST 2017
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":
then it generates an error message, as expected:
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.
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
On 4/6/17, 12:30 PM, "R-help on behalf of Bert Gunter" <r-help-bounces at r-project.org on behalf of bgunter.4567 at 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. <CR> ; 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).
"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 <bpschn01 at gmail.com> wrote:
> 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
> 3 print( getLineNumber() )
> 5 # End of script
> Thanks for any ideas!
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help