I've created very simple package, using RStudio, to demonstrate my problems, the steps follow.
- Create package with only one function
write <- function(text) {
print(text)
if (is.numeric(text))
stop("Text cannot be numeric.")
}
Build -> Install and Restart
In a new R Script, write following code
pckgname::write(1)
Result in Console:
tempPackage::write(1)
[1] 1
Error in tempPackage::write(1) : Text cannot be numeric.
Called from: tempPackage::write(1)
Browse[1]>Problems
5a) I don't want to see "Called from: tempPackage::write(1)".
5b) More importantly, I don't want to end with "Browse[1]> " meaning debug mode is still open (also buttons like "Continue" and "Stop" are visible) so now I need to click on button "Continue" to finish debug mode to end on line with ">" but I want to end this debug mode without clicking on button "Continue" meaning when I run that one line code "tempPackage::write(1)" I want to see result in Console with finished debug mode.
Additional information:
- When I use this stop in function directly in the same R Script (not called from a package), it works like I want.
- Solution using following method also doesn't help with previous problems.
opt <- base::options(show.error.messages = F)
on.exit(base::options(opt))
- When I found some solution e.g. on GitHub e.g. https://github.com/jakesherman/easypackages/blob/master/R/package.R and installed them and intentionally made an error then again I get what I wanted (debug mode ended and no message Called from shown).
Thank you for any help in advance.