LINENO.RdGet the line number of the executing expression.
LINENO(n = 0, envir = parent.frame(n + 1),
matchThisEnv = getOption("topLevelEnvironment"),
srcfile = if (n) sys.parent(n) else 0)See ?this.path().
LINENO() only works if the expressions have a
srcref.
Scripts run with Rscript do not store their srcref, even when
getOption("keep.source") is TRUE.
For source() and sys.source(), make sure to supply argument
keep.source = TRUE directly, or set options "keep.source" and
"keep.source.pkgs" to TRUE.
For debugSource() in ‘RStudio’, it has no argument keep.source, so set
option "keep.source" to TRUE before calling.
For compiler::loadcmp(), the srcref is never stored for the compiled
code, there is nothing that can be done.
For utils::Sweave(), the srcref is never stored, there is nothing
that can be done.
For knitr::knit(), the srcref is never stored, there is nothing that
can be done. I am looking into a fix.
For package:targets, set option "keep.source" to TRUE before
calling associated functions.
For box::use(), plumber::plumb(), shiny::runApp(), and
testthat::source_file(), the srcref is always stored.
integer; NA_integer_ if the line number is not found.