Skip to content

Instantly share code, notes, and snippets.

@derrickturk
Created February 6, 2014 00:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derrickturk/8836186 to your computer and use it in GitHub Desktop.
Save derrickturk/8836186 to your computer and use it in GitHub Desktop.
Javascript style "immediately invoked function expressions" plus on.exit for scope guards in R. Cleanup actions get carried out regardless of clean or error exit from block.
(function() {
pdf("example.pdf")
on.exit(dev.off())
plot(some.data)
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment