R: Error in fBody[[i]] : no such index at level 4
11,490
Solution 1
This is a bug in RStudio. I frequently get it while writing my R code. This is all I always do and work:
- Restarted RStudio
- Clear all breakpoints (there is a menu for that)
- Cut the entire source code, the file you want to debug. Save the empty file.
- Paste the source code. Save it.
The bug has something to do with position of the breakpoints. For some reason, RStudio is confused the new breakpoints with something else. By cutting and pasting the source code, we are forcing RStudio to "forget" the old breakpoints and start refresh. It's like giving a new file to RStudio.
Now, you can run a debug session again.
RStudio developers, please fix this stupid bug.
Solution 2
On mac, I usually use:
- Save file
- Debug->Clear All Breakpoints.
It helps even without restarting RStudio
Solution 3
- Save file without breakpoints
- Session -> Restart R
Usually works for me...
Author by
Massyanya
Updated on June 27, 2022Comments
-
Massyanya almost 2 years
Debug mode in R sometimes throws out the following error:
Error in fBody[[i]] : no such index at level 4
What causes this? And how to avoid it?
-
Craig S. Anderson over 7 yearsNote that it is over a year since the question was asked and the bug is still present.
-
Stuart Lacy about 7 yearsBug still present in RStudio 1.0.136. This solution still works thankfully.
-
3pitt over 6 yearsin the new version, it looks like simply clearing breakpoints and re-sourcing is sufficient
-
Gürol Canbek about 6 yearsStep-2 and step-1, respectively, works for me on macOS.
-
Kamran about 5 yearsWorks like a charm in Windows!
-
kummerer94 almost 5 yearsDoes not do the trick for me running RStudio 1.2.1335. I cannot believe this bug made it this far. It is unbelievably annoying.