Skip to content

Instantly share code, notes, and snippets.

@hrbrmstr
Last active June 1, 2018 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrbrmstr/c07ddf290369d954a54443b6b09faae3 to your computer and use it in GitHub Desktop.
Save hrbrmstr/c07ddf290369d954a54443b6b09faae3 to your computer and use it in GitHub Desktop.
options(viewer = function (url, height = NULL, append=FALSE) {
# USE AN ENVIRONMENT SEPARATE FROM GLOBAL BUT ACCESSIBLE
# THIS WILL MAINTAIN CURRENT OUTPUT FILE LOCATION
# IF append IS TRUE THEN INSERT THE NEW HTML AT THE END OF THE FILE
# THERE ARE LOTS OF WAYS TO DO THIS. ONE IS IFRAME-ing EACH AS THEY
# ARE APPENDED. ANOTHER IS TO JUST SMUSH THEM ALL TOGETHER
# MAKE url THE FILE WE JUST MODIFIED
# IF append=FALSE DON'T WORRY ABOUT ANYTHING AND JUST USE url
# THE REST OF THE CODE STAYS PRETTY MUCH THE SAME
if (!is.character(url) || (length(url) != 1))
stop("url must be a single element character vector.",
call. = FALSE)
if (identical(height, "maximize"))
height <- -1
if (!is.null(height) && (!is.numeric(height) || (length(height) !=
1)))
stop("height must be a single element numeric vector or 'maximize'.",
call. = FALSE)
invisible(.Call("rs_viewer", url, height))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment