Show line number on error when searching R script from command line

Consider the following R

file ( C:\Users\Pedro\Desktop\test.R

):

f1 <- function() {
  print("A")
}
f3()

      

If I post this file from the R console:

options(show.error.locations=TRUE);source('C:\\Users\\Pedro\\Desktop\\test.R')

      

then the line number will be printed correctly with the error message:

enter image description here

However, if I run the above command from windows cmd prompt by doing:

R --slave --restore --no-save -e "options(show.error.locations=TRUE);source('C:\\Users\\Pedro\\Desktop\\test.R')"

      

Then there is no line number:

enter image description here

So my question is, how can I get the line number in the error message when searching for R file from windows cmd prompt?

+3


source to share


1 answer


Usage is keep.source=TRUE

similar to my problem:



options(show.error.locations=TRUE);source('C:\\Users\\Pedro\\Desktop\\test.R', keep.source=TRUE)

      

+1


source







All Articles