Yu Le
Yu Le

Reputation: 243

R language: how to clear the frames/stack in Rstudio/console

By stack, I refer to the output from traceback() upon error condition. How does one 'clear the stack' so one gets 'No traceback available' from traceback()? thanks

Upvotes: 4

Views: 604

Answers (2)

Rachel Gallen
Rachel Gallen

Reputation: 28563

you could always do this

 getOption(showWarnCalls, FALSE)
 getOption(showErrorCalls, FALSE)

Upvotes: 0

James
James

Reputation: 66834

It can be done by overwriting the .Traceback variable which is currently stored in the base namespace:

stop("Hammer Time!")
Error: Hammer Time!
traceback()
1: stop("Hammer Time!")
assign(".Traceback",NULL,"package:base")
traceback()
No traceback available

Be warned though:

It is undocumented where .Traceback is stored nor that it is visible, and this is subject to change.

Upvotes: 5

Related Questions