Created
June 27, 2022 23:50
-
-
Save MilesMcBain/d2599f31e187ead226aa1b2355efbe15 to your computer and use it in GitHub Desktop.
cloud_view()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
) | |
} |
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
If you have this in your
.Rprofile
anytime you want to view the output of a{htmlwidget}
in VSCode when working over ssh, you pipe it tocloud_view()
. Not ideal, but better than having nothing. If you use this a lot you'll accumulateservr
instances, which you'll probably want to clean up,servr
has a number of functions for handling this.