How do I turn off degugging of `[.data.frame` in R? - r

I am stuck in the debugger. I had an error in a function I ran using RStudio. I clicked the rerun with debugger and now every time I run it, it starts the debugger and I can't stop it.
It tells me that the function being debugged is [.data.frame however if I try `undebug('[') or undebug('[.data.frame') I get
Warning message:
In undebug([) : argument is not being debugged
I have restarted RStudio, but that does not help either. I have tried running some of the functions from this SO question to no avail.
Any ideas?

Then try this
"Debug" -> "On Error" menu and select "Message only"
click here for more informations

Related

Error in file(out, "wt") : cannot open the connection when selecting functions

I know that this error has been asked often but I've checked most of the questions and none of them have the same cause as mine, at least on the surface.
I work in Rstudio. The console lets you write functions and offers suggestions, for example if I start typing "ex" the first option will be the "exp" function:
(example)
The problem is that everytime that the suggestion box appears there is a small time (usually a second or two) before a pop up window appears, saying "Error retrieving help. R code execution error" and in the console the text in red says: "Error in file(out, "wt") : cannot open the connection". Fortunately the console command that I'm writing doesn't get deleted but it is still very annoying and sometimes I want to use the suggestion box to save time but it feels that I have to rush to select the function before Rstudio punishes me.

How to print in r source stops

have a code that calls different codes inside it with source function. if an error occurs when running a source i would like to save the information of the error that appears but im not being able to do it. Does anyone know if this is possible? Thanks!
Did you try traceback() after the error occurred? You can also set it in options(error = traceback). I think RStudio IDE provides tracebacks by default.

stop() in package function doesn't end debug mode

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.
I just did exactly as you instructed and I see the expected result:
pckgname::write(1)
[1] 1
Error in pckgname::write(1) : Text cannot be numeric.
I'm not sure what's wrong when you try it, but would recommend starting a fresh package in case something is not working correctly. You could even try reinstalling R and RStudio, as it worked first time for me and I can't think of why it wouldn't for anyone else.
For reference, here's exactly what I did:
I started the package from RStudio -> File -> New Project -> New Directory -> New Package
The only file I changed was hello.R - I added the code in your question exactly as-is.
I built the package with RStudio -> Build -> Build from source
And then installed it with install.packages("../pckgname_0.1.0.tar.gz", repos = NULL, type="source")
And loaded with library(pckgname)

What is this error in RStudio: "breakpoints will be activated when the file or function is finished executing"?

I am trying to set a break point inside a function from a package I wrote. I am unsuccessful when clicking next to the line number in Rstudio, the error message looks like:
I am not executing anything. Reloading the package did not help either. What is this error and what can I do about it?
Check out this documentation from RStudio that explains what to do.
Basically, make sure you save your R file, then click the Source button on the toolbar:
Your breakpoint should then turn from a hollow red circle to a full one.
Usually running rm(list=ls()) will do the job.

R Debugging - Cannot see which line generates warning message (Shiny)

Is there a way to make Rstudio tell you which line of which sourcefile generated a warning message?
Right now it just prints the message and I am lost as to what is causing the issue.
In Rstudio, this menu option is checked:
Debug > Error > Error Inspector
But it doesnt' help, probably because these are warnings and not errors? Ideas?
First turn on displaying warnings using the command
options(warn=1)
Then, you could run it by clicking on the "Source" or "Source with Echo" button (see image below). You can see the error/warning messages when any line with errors/warnings is executed.

Resources