You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've learned on.exit in the book and it is really helpful. But setting the parameter add to TRUE get me a little puzzled, and the after argument might just make it harder to know the order of expressions. If the contents in on.exit would just run in the end, why not wrap them up? Which mean:
Imagine R keeps a list of commands which need to be executed when exiting. The current implementation allows you to do one of three things:
Place commands at the end of the list (add=TRUE, after=TRUE)
Place commands at the beginning of the list (add=TRUE, after=FALSE)
Replace the list (add=FALSE, after=TRUE or after=FALSE)
What you have suggested is not wrong, and it even makes sense if you only call on.exit once in your program, but the arguments of on.exit are there to support the more general functionality described above.
I've learned
on.exit
in the book and it is really helpful. But setting the parameteradd
to TRUE get me a little puzzled, and theafter
argument might just make it harder to know the order of expressions. If the contents inon.exit
would just run in the end, why not wrap them up? Which mean:could be used as:
In this style, we do not have to figure out which codes would be evaluated first. Wonder if this style would be better.
Thanks.
The text was updated successfully, but these errors were encountered: