Skip to content

Instantly share code, notes, and snippets.

@MilesMcBain
Created June 27, 2022 23:50
Show Gist options
  • Save MilesMcBain/d2599f31e187ead226aa1b2355efbe15 to your computer and use it in GitHub Desktop.
Save MilesMcBain/d2599f31e187ead226aa1b2355efbe15 to your computer and use it in GitHub Desktop.
cloud_view()
cloud_view <- function(obj) {
withr::with_options(
list(viewer = function(url, ...) {
get_url_dir <- function(url) gsub("file://|/index.html", "", url)
server <- servr::httd(
dir = get_url_dir(url),
verbose = TRUE,
browser = FALSE
)
.vsc.browser(server$url, ...)
}),
print(obj)
)
}
@MilesMcBain
Copy link
Author

I assume there was a reason I didn't just set the viewer option to this in my remote .Rprofile, I suspect it's to do with wanting to avoid messing with other things that do work fine, like Shiny apps, but I can't remember.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment