I have some statements that run in various programs--some in development, some in production--so it is confusing when I get a message and don't know in what program the statements were imbedded. Instead of modifying each set of statements and adding manually the name of the program where it is running, I would like the statements to report their status by themselves.
Thus, it would be nice to have one function that tells me in which program they are running. Something like, "This is 'xyz' and I'm running in code1.R". If exactly the same set of statements run in another program, they would say, "This is 'xyz' and I'm running in code2.R".
At the same time, given that some of my programs are big and I keep adding or deleting lines, it would help if another function states in what line a statement is located. In this case it would be, for example, "This is line 345". If I delete two lines before this one and I run the same program, it should say, "This is line 343".
Pseudo-code:
x <- function(?) # this identifies where these lines are running
y <- function(?) # this identifies in which line the statement is written
print(paste("I'm running from this R program:", x()))
print(paste("... and this is row number:",y()))
print(paste("... while this is row number:",y()))
The output should be:
I'm running from this R program: code1.R
... and this is row number: 4
... while this is row number: 5
Perhaps this functionality exists in the current setup or packages, but I didn't find it yet.
Thanks