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
The following function can change the default viewer settings between using the A) the Rstudio viewer, and B) opening a separate window. All HTML plots, Rmarkdown reports, shiny apps, etc. will be affected for the remainder of the R session:
Function
#' Set viewer option#'#' @param .view Method for viewing the R object#'#' @keywords internalset_window_viewer<-function(.view= c("window", "viewer")) {
.view<- match.arg(.view)
view_call<-switch(.view,
viewer=rlang::quo(function(url, height) {
invisible(.Call("rs_viewer", url, height, PACKAGE="(embedding)"))
}),
window=rlang::quo(function(url, height) {
invisible(.Call("rs_showPageViewer", url, title="RStudio", self_contained=FALSE))
})
)
view_fn<-function(url, height=NULL) {
if (!is.character(url) || length(url) !=1)
stop("url must be a single element character vector.", call.=FALSE)
if (identical(height, "maximize"))
height<--1if (!is.null(height) && (!is.numeric(height) || length(height) !=1))
stop("height must be a single element numeric vector or 'maximize'.", call.=FALSE)
# Evaluate the quoted expression in the environment of view_fn
eval_tidy(view_call)(url, height)
}
options(viewer=view_fn)
}
Use
> set_window_viewer("window")
>result# opens as a new window> set_window_viewer("viewer")
>result# opens in viewer
The text was updated successfully, but these errors were encountered:
The following function can change the default viewer settings between using the A) the Rstudio viewer, and B) opening a separate window. All
HTML
plots,Rmarkdown reports
, shiny apps, etc. will be affected for the remainder of the R session:Function
Use
The text was updated successfully, but these errors were encountered: